Posted in December 2007

Pimp my ‘clipse – a list of must-have Eclipse plug-ins for Flex/Flash Development

by

Eclipse Rims

FlexBuilder may have its ups and downs but it still remains my pick for best AS3/MXML editor on the market (with TextMate not far behind). Part of the beauty of FlexBuilder is that it’s built on the Eclipse SDK, one of the most versatile and powerful IDEs available, which is not only free and open source, but boasts a wealth of third party plug-ins for every kind of (mostly Java) development. This article will take a look at some must-have plug-ins for doing Flex development as well as some tips for tricking out your development process.

As with all of our entries, your feedback, suggestions, corrections and additions are all more than welcome.

Continue reading

Good Websites have Good Content

by

Tonight I wanted to check out some information about a video game so I turned to a site that both Roger and I worked on while at Schematic – Game Invasion. I think this site is great but I’m not here to toot my own horn. We built this with Flash 8 in under 2 months and it certainly isn’t technically perfect. However, even though this site is two years old and takes a while to load, I still really enjoy using it. I started wondering why.
The reason is simple – content (the graphic design is pretty good too). What makes this site great was not the work we did but the incredible amount of really high-quality content. There are HD videos, big crisp graphics and something new every time I visit. There are other sites that I’ve spent way more time making perfect that I’d never look at again since there’s nothing really worth seeing.
Another example is the NBC episode player. It’s buggy as hell and the ads are annoying. I much prefer the ABC player. However, I really like the show ‘Heroes’ so I pretty much forget about those things in the end.
What I’m trying to say here is that technical brilliance and good design are great but what will keep people coming back to your site is some really great content so if you’re making a website make that your focus.

Weak vs Strong References in AS3

by

For those of you not familiar with the concept, a weak-reference is a reference to an object that will not hold the linked object in memory when that object is garbage collected.

There are only two ways to create a weak reference in AS3. The first is with the IEventDispatcher.addEventListener() method which allows you to create a weak link between the dispatcher and the listener. To quote the AS3 Bible:

ActionScript 3.0 introduces the concept of weak and strong memory references. Normally, an object will be garbage collected if there are no references to the object. That is, when no objects are using a variable, it gets thrown out. Weak references allow you to reference an object but the object will still be eligible for garbage collection unless another object holds a strong reference to the object. By setting the [addEventListener() method's] useWeakReference flag to true, you will create a weak link between the event broadcaster and the event listener. That way, if an dispatcher is deleted while there are still listeners attached, the weak reference will allow it to be garbage collected. This helps to prevent memory leaks.

The other way is with the objects used as keys in a Dictionary object.

ActionScript, unlike many other languages, does not have a way to explicitly remove an object from memory. Instead it waits until all references to an object are removed and then auto-deletes it. Therefore, an object will continue to stay in memory if all strong references aren’t removed.

Below is an example of how strong-references hold an object in memory. If you’d like to try this out, copy the below text into a file called StrongReferencesExample.as

package {
	import flash.display.Sprite;

	public class StrongReferencesExample extends Sprite {
		public function StrongReferencesExample() {
			// create a new object called dog. Add it to the first leash object
			// and make leash2 a copy of leash 1.
			var leash1:Object = new Dog();
			var leash2:Object = leash1;

			// tracing both leashes will show that they hold a reference to the Dog
			trace(leash1); // [object Dog]
			trace(leash2); // [object Dog]

			// deleting the dog from the first leash will not remove it from the second leash
			// even though we originally set leash2 equal to leash1
			leash1 = null;
			trace(leash1); // null
			trace(leash2); // [object Dog]

			// The object (dog) will not be free until all of the references to it (leashes) are broken.
			leash2 = null;
			trace(leash1); // null
			trace(leash2); // null
		}
	}
}
// Define a simple Dog class within the same file.
class Dog {}

Richard Lord over at Big Room Games has an interesting article on hacking AS3 to allow you to create weak-references to objects. The hack is pretty decent but lacks a few things I’d like to see like strong typing at compile-time or a more refined ‘memory manager’ type functionality. However, I tried implementing both of these and came up empty handed. If you can think of a way to make this strong-typed, I’ll give you a candy bar.

Using the WeakReference hack could be useful if you want to make sure that an object will not stay in memory if you forget to delete all references to it. However, keeping track of your objects and practicing good memory management is a much better solution and hacks like this one should be saved for special cases where tracking use of an object becomes difficult or impractical.

Thanks to Alex for the link!

Preventing Out-of-memory errors in Eclipse / FlexBuilder

by

You may occasionally get an error that Eclipse has run out of memory. Part of the problem here is that Eclipse is only allocated 256MB of RAM by default. I’ve found this can be helped (but I sometimes still have problems) when I set my maximum memory allocation to a larger value such as 1024MB. Detailed instructions for how to do this can be found on the Eclipse help site.

If you like playing with runtime arguments like memory allocation, don’t stop there. Check the list of command line arguments on the help page listed above. I use -nosplash which prevents the eclipse logo from coming up during startup. Cleaning the Eclipse application with -clean can be useful too especially after installing plugins or when things are breaking for no reason. (Mac users can skip the tedious .ini editing process and do this by typing /Applications/eclipse/eclipse -clean in the terminal.