AS3.0和AS2.0有了很多变化,以下是“AS3.0:调用SWF文件”的一个例子(其中yanshi是一个按钮):
yanshi.addEventListener("click",play_child);
function play_child(evt:MouseEvent){
var request:URLRequest = new URLRequest("test.swf");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.load(request);
addChild(loader);
}
function loadProgress(event:ProgressEvent):void{
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
}
function loadComplete(event:Event):void{
}