Les Stroud is back at it

I just heard that my former employer Les Stroud┬áis going to be doing more episodes of Survivorman – but this time for 10 days instead of 7.

If you’re not familiar with Survivorman you should be. It basically invented the Survival TV genre – and no not the reality TV, I can win a car crap – the real stuff where people are actually required to know how to do it.

I loved the show and am definitely looking forward to the new episode(s) both as a fan and a friend of Les’ and I wish him and the Les Stroud Productions team the best.


I have been creating a code base for a Screen Manager system that I am using for an iOS app I am building in AS3. I wanted to create a dynamic way to reference and instantiate classes that represent each of the Screens in the app so I can reuse this for other applications in the future and to make it a lot less code intensive.

I setup a series of static variables that held string names to represent each of the Screens in the application. Then when I want to create the screen and add it to the stage I use the getDefinitionByName() method and pass the string name of the class. Continue reading “getDefinitionByName”

Set it and forget it

I was writing a post about Events in AS3 and while explaining why in my opinion one approach to passing data is preferable to another I stumbled across the phrase “Set it and forget it” when it comes to programming. I think that this is a great way of describing how I like to write code and is a pretty good way of determining when a certain functionality should be abstracted into it’s own class or sub class.

The basic concept is that as a programmer I shouldn’t need to remember anything special about the class I have just written.

Obviously I’m not referring to things like a particular method or getters/setters but rather little gotchas that you won’t remember 6 months after writing the class.

For example, I was writing an ImageLoader utility class and added some functionality to create a thumbnail dynamically using the BitmapData class. I was pretty happy with the class and it worked very easily, once the data was available an Event was fired and a Getter method was called to return the bitmap. The only issue was that I was returning a Bitmap and MouseEvents are not triggered by Bitmaps so I was having to wrap the Bitmap in a Sprite and then assign listeners. As you can see, the extra step I have to remember is tedious and so I re-approached the class and wrapped the Bitmap in a Sprite before returning it. No fuss, no muss. Now I can just use the class without having to remember anything. I can “Set it and Forget it”

Weak Listeners

Garbage collection can be a big deal when writing complex programs in Actionscript. Not removing EventListeners is probably one of the biggest sources of AS holding onto memory it doesn’t need.

There is a very easy way to allow GC to handle your event listener clean-up for you when creating a new event listener – the useWeakReference argument.

Here is some standard code we’ve all done million times when creating a button:

var button:MovieClip = new MovieClip();
button.addEventListener(MouseEvent.CLICK, click_handler_function);

The two arguments are pretty straight forward the first is the event we’re listing for and the second is the function that is called once the event is fired, but there are actually 5 arguments that can be passed to addEventListener() here is the method definition:

addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

the 5th argument (useWeakReference) is false by default but by setting to true, this eventListener will be automatically removed and freed for Garbage Collection when required.

Here is the new eventListener code updated to make use of useWeakReference.

button.addEventListener(MouseEvent.CLICK, click_handler_function,false,0,true);

3 Jewels in my Crown

3 Jewels in my Crown was a very fun WordPress theme to work on. It features many different custom image sizes based on a Featured Image and does all of the resizing work for the user. One really great feature is the ability to select certain posts as “Featured’ by using a custom taxonomy I set up. I could have used a category for this but wanted to avoid any duplicate content issues with search engines.

Overall this was a great learning experience for me and I really dove into the lower level features that WordPress has to offer.

Castfire AS3 Library

I have been developing an AS3 library for the video publishing company Castfire on my own for the past little while and recently got in touch with them about continuing the endeavor. I thought it was a shot in the dark but they were more than willing to help out and so here is the first of, I hope, many articles on the Castfire API and the class library I am working with them to create for it.

The point of this library is to allow Flash devs like myself to easily access the Castfire API when creating custom video players.

Continue reading “Castfire AS3 Library”