I am developing a project in Flash Builder which will load a file built by Flash CS4. The code in Flash CS4 is below, it’s a doc class. I am sure the dispatchEvent has been invoked:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class flashcs extends MovieClip
{
public function flashcs():void
{
dispatchEvent(new Event("onPlayerLoaded", true));
}
public function playVideo():void
{
return;
}
}
}
In Flash Builder, I use below code to listen to the event, but the callback never get called:
private function playerLoaded():void
{
Player = MovieClip(Loader.content)
Player.addEventListener("onPlayerLoaded",Callback);
}
mx:SWFLoader id="Loader" source="http://localhost/flashcs.swf" init="playerLoaded()"
I think maybe I can only listen to a SystemManager but not on the MovieClip? Because I have one prior project, the loaded swf file is built by Flash Builder, I was listening to the SystemManager without any trouble.
Thanks.
Try within the
complete eventnot theinit, if thedispatchEventhave been fired before you have been able to listen to it you will not get it.Edit:
In your loaded class delay the dispatch event to fired it when object is added to the stage: