complete
使用SWFLoader 事件加载 SWF 后,尝试引用 MovieClip 。可以从event.target.content
完整的事件处理程序中访问您的 MovieClip。然后,您可以stop()
直接调用 MovieClip,看看是否有效。请参见下面的示例:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
>
<fx:Script>
<![CDATA[
public var mc:MovieClip;
protected function swfloader1_completeHandler(event:Event):void
{
mc = event.target.content as MovieClip;
mc.addEventListener(Event.ENTER_FRAME,newFrame);
mc.stop();
}
protected function newFrame(event:Event):void
{
if( mc.currentFrame == mc.totalFrames )
{
mc.stop();
mc.removeEventListener( Event.ENTER_FRAME, newFrame );
}
}
protected function button1_clickHandler(event:MouseEvent):void
{
mc.gotoAndPlay(1);
}
]]>
</fx:Script>
<s:SWFLoader source="[REFERENCE TO YOUR SWF]" complete="swfloader1_completeHandler(event)"/>
<s:Button label="Play" click="button1_clickHandler(event)" />
</s:Application>