An Interesting MX 2004 Migration Issue: Case Sensitivity and Scope
I'm in the process of migrating Opal, our Enterprise SMS Messaging RIA for Telrock Communications, from Flash MX To MX 2004 and I just ran into a very interesting issue that appears to be related to case sensitivity and variable scope. The migration, at this point, does not involve a move from AS1 to AS2 -- it is purely aimed at a Flash MX 2004 recompile optimized for the Flash 6r65+ player to reap the performance gains.
Returning to the issue at hand, the following code works in Flash MX:SomeCommand.prototype.execute = function( viewRef ) { var someBusinessDelegate = new SomeBusinessDelegate( this ); someBusinessDelegate.someMethod();It does not work, however, when compiled in Flash MX 2004 (the someMethod() method of the SomeBusinessDelegate is not called.) I am guessing that either SomeBusinessDelegate is undefined or it somehow shadows the local variable, someBusinessDelegate. I say "guessing" because if I add a trace, to check the typeof SomeBusinessDelegate, the darn thing works! :) So, this works: (How weird is that?)}
//... trace (typeof SomeBusinessDelegate); var someBusinessDelegate = new SomeBusinessDelegate(); //...Don't you just love these situations? It's like an awkward moment of silence where you're staring at Flash, Flash is staring at you and you're pretty much speechless. I think if Flash could blush it would, perhaps even manage a shy smile and shrug its shoulders as if to say: "Oops!.. oh well!"
Skipping over the Miracle Trace Fix (tm), I tried changing the name of the local variable from userDelegate to lUserDelegate and voila... the business delegate got called.
I'm guessing that this is some sort of scope issue that behaves differently in Flash MX and Flash MX 2004. Definitely one to watch out for!
Now I venture bravely on to solving some other fascinating migration issues (can you hear the drums? The trumpets?) :)
Comments
by onRelease() :: New Post On FlashAnt.org on 2003-12-10 18:59:20
by How to Get Six Pack Fast on 2009-04-15 17:04:08