This content has been marked as final. Show 10 replies
is 1.swf completely loaded before app.swf loads?
Yes, there's no doubt that both swf files are fully loaded before the singletons are created.
When run in a browser I see the following two lines in the debug output :
[LOG]../framework_apps/sketchy/new_canvas.swf Aquired existing singleton "globals" = [object Object]
The second line indicated that the return value from the function that output the first line has become undefined en route somehow.
When run locally, the second line instead says:
[LOG]swatch_handler: singleton= [object Object]
is this a non-flash issue? are these all swfs that are interacting?
show your getSingleton() code and one of the failing function calls from an app.swf movieclip.
Here's the code in question:
is that code in app.as?
No, just part of it. There's alot of code involved, I was trying to distill the relevant parts out, but perhaps not in the best way.
There are two classes involved, one attached to a clip in 1.swf and the other attached to a clip in app.swf.
The one in 1.swf is the window manager. It contains the array of windows and manages their z-order. It loads in new swfs as applications, and looks after their titlebars and so-on. It also provides API by attaching functions to _root, so that they are available to the loaded applications. It exposes the function getSingleton in this way. Naturally this is a fairly large class, and I didn't want to attach the entire thing, the functions getSingleton, findObject and findObjectFromClip are defined on this class.
The class in app.swf is included in its entirity, and it's the constructor of this class that calls the getSingleton function and exhibits the behaviour. There are several classes in app.swf that use the getSingleton function and they all behave in the same way, ending up with the correct object when run locally, and with undefined when run remotely.
There's no doubt that 1.swf is fully loaded before everything happens, and all the expected debug statements appear in the debug output.
I have discovered that this line:
in my debug trace function, which is called from the get singleton code, causes the get singleton function to return undefined.
I have reproduced this in a much smaller test application, in which the get singleton code is replaced by a function that simply returns a new object. If this function calls my debug trace function, then the new object is returned as 'undefined'. If it does not call the debug trace, or if the debug trace is modified so that it doesn't actually call getURL, then the problem goes away.
Do you (or anybody else) have any idea what might be going on.
Note that when run locally, the getURL function is not called since the debug trace function tests:
System.security.sandboxType == "remote"
in order to avoid opening browser windows when running from within the flash IDE.
And the answer is:
because it's broken, and will cause very strange behaviour. eg:
for(x in y) loops terminating unexpectedly
return values from function calls going missing
Instead. It works properly.