It's actually very close to what Jochen Hilgers suggested. However, in this instance, the event you want is actually INIT
instead of COMPLETE
. INIT
is fired when the content is not yet fully loaded but is ready for use (and will start playing on its own).
Attach the event with
loader.contentLoaderInfo.addEventListener(Event.INIT, handleReady );
And handle it with
public function handleReady( initEvent:Event ):void{
MovieClip(initEvent.currentTarget.content).stop();
}
You'll notice that you can cast the content
property of currentTarget
as a MovieClip and stop it even before it has been attached to the stage.
It is important to note that it is not safe to use the content
property in a PROGRESS
event (or any time prior to an INIT
or COMPLETE
event). You will get an error to the effect that the object is not ready.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…