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?) ![]()
The An Interesting MX 2004 Migration Issue: Case Sensitivity and Scope article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.
1 Response to “An Interesting MX 2004 Migration Issue: Case Sensitivity and Scope”