Archive

Archive for April, 2009

Application Domain and External SWF Loading

April 6th, 2009 9 comments

Why do we care about application domains? I worked on a project that required me to load and unload SWF files into a bigger application (loading mini-games into a virtual world). Every time I loaded a mini-game, it would never unload when I exited it. That will keep accumulating until the app slows down to a crawl and crash because we’re out of memory.

The application domain and definition loading is one of the things that is not documented in a way the common mortal can understand. By popular demand, I will attempt to explain it the way I understand it. I will provide some examples along the way. Before I continue, here is a link to the official documentation on ApplicationDomain.

I will explain class definitions and domains, and then tell you what you can do to properly unload your movies and assets.

Class Definitions

Everything that you load has to be stored somewhere. It’s easy to understand the visual elements because you can just stick them on the stage. But what about class definitions?

Read more…

AS3 Mystery: null, false, 0, “”, NaN

April 2nd, 2009 2 comments

This week I’ve been running unit tests and couldn’t understand why some of them were failing for no obvious reason. To understand why some expressions evaluated to true when they were supposed to be false. I know that I should be careful with null vs false values, but never could I have imagined that the Number 0 can be equal to an empty String!

I know that php’s empty() function is quite permissive, but I though AS3 was much more strict (with strict typing and all). And so I ran a different kind of test, where I checked these values in depth. Here is a table describing my results.

  null false 0 “” NaN
isNaN()          true
== “”   true true true  
=== “”       true  
== null true        
=== null true        
== 0   true true true  
=== 0     true    
== false   true true true  
=== false   true      
is Number     true   true
is String       true  
is Boolean   true      
is Object   true true true true

 You will notice that NaN is actually a Number and an Object, that 0 == “” == false and that false is actually an Object. There are quite a few surprises in there that will make me appreciate strict comparison.

Tags: ,

April Fools’ Prank on my CTO

April 1st, 2009 No comments

Today the development team decided to make the CTO freak out. Here is what we did to the application currently in development:

  • Play the Skype ringing tone in a loop
  • Prevent important data from loading
  • Hide the CLI after 1/2 second (long enough to see it appear)
  • On the 3rd run, display a fake Confickr C popup that seems like it’s uploading financial data, with a nice progress bar and all
The effect exceeded our expectations. Everybody had a good laugh at the end.
Tags: