预加载器未完成时正在播放外部swf。我无法访问外部swf.My代码(AS 3.0)
package com
{
public class MainClass extends Sprite
{
private static var file:String = "Movie.swf";
private var loader:Loader;
static var txt:TextField = new TextField ;
static var format:TextFormat = new TextFormat ;
format.color = "0X003333";
format.font = "Arial";
format.size = "38";
txt.defaultTextFormat = format;
public function MainClass()
{
loader = new Loader ;
loader.load(new URLRequest(file));
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,preLoad);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,showContent);
}
private function preLoad(e:ProgressEvent):void
{
var perc = e.bytesLoaded / e.bytesTotal;
txt.text = Math.ceil(perc * 100).toString();
txt.x = stage.stageWidth / 2;
txt.y = stage.stageHeight / 2;
mc.addChild(txt);
}
private function showContent(e:Event):void
{
mc.removeChild(txt);
mc.addChild(loader);
mc.x = stage.stageWidth / 1 - mc.width / 1;
mc.y = stage.stageHeight / 1.5 - mc.height / 1.5;
}
}
}
答案 0 :(得分:0)
如果你加载的MC是时间轴动画,你应该放一个Stop();到第一帧。然后在你真正完成加载时启动它。