0
外部SWF播放時預加載不完整地填寫不能訪問外部swf.My碼(AS 3.0)外部SWF播放時預加載未完成
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;
}
}
}