I have found solution to the 'onLoad' problem, but it is maybe not perfect. The page is at
http://yetagain.net/sandbox/flashtest2/ (With Actionscript source at http://yetagain.net/sandbox/flashtest2/Tuto.as ) The thing that I found was that for a callback called "onFlashLoad" (onLoad caused problems!), to access that function from Actionscript I need to call: ExternalInterface(_root.onFlashLoad, "some data to pass"); and not, as I was doing: ExternalInterface("onFlashLoad", "some data to pass"); as that actually tries to call the *global* Javascript function "onFlashLoad". *However* this is still not perfect. I want to find the earliest possible time I can call the Flash function "actionscriptFunction" from Javascript. If I try to call this Flash function from the onFlashLoad handler, the browser crashes. I think this is because all calls are *synchronous*, and so a deadlock occurs: the SWF file is waiting for its onFlashLoad call to finish before it can move on to deal with the "actionscriptFunction" call. However, in Javascript, the onFlashLoad call won't finish until the actionscriptFunction finishes. Therefore I have to set a delay of 1ms before I can call Flash from Javascript. If anyone knows a way around this hack, I would be grateful! Michal. On Jan 15, 11:15 am, Michal <[email protected]> wrote: > Hi, > > I've trying to get Javascript->Flash communication working. I am a > Flash newbie, so I don't really know what I'm doing. I have managed to > get Javascript -> Flash calls working at: > > http://yetagain.net/sandbox/flashtest/ > (With Actionscript source athttp://yetagain.net/sandbox/flashtest/Tuto.as > ) > > *However* if you examine the code, you will see that this > communication happens after a delay of 1 second. If I try to make the > call as soon as the Swiff object is instantiated, then I get an > __flash__argumentsToXML is not defined error. > > Therefore I need some sort of 'onLoad' event from the Swiff object. > Examining previous posts, it looks like I need a callback function > from Flash -> Javascript to tell Javascript that it is ready to start > receiving calls. As you can see from the code I have set this up > using the 'callBacks' parameter passed to the constructor of the Swiff > object, and I call this function "onLoad". I then call "onLoad" from > the Actionscript using ExternalInterface.call. > > *However* this callback function is never called. I'm unsure if this > is an issue with my Actionscript or my Javascript. In any case, I am > stuck. > > Does anyone have any ideas? > > Michal.
