ActionScript 3 装载机
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 装载机相关的知识,希望对你有一定的参考价值。
package com{
import flash.display.MovieClip;
import flash.display.LoaderInfo;
import flash.events.*;
import flash.net.URLRequest;
import flash.display.Loader;
public class Host extends MovieClip
{
private var request:URLRequest;
private var cont:Loader;
private var loadedClip:MovieClip;
public function Host():void
{
request = new URLRequest("start.swf");
cont = new Loader();
cont.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
cont.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
cont.contentLoaderInfo.addEventListener(Event.INIT, onInit);
cont.visible = false;
try {
cont.load(request);
}catch (error:SecurityError){
trace(error);
}
addChild(cont);
}
private function onInit(event:Event):void
{
if (event.target is LoaderInfo){
loadedClip = event.target.content as MovieClip;
trace(loadedClip);
}
}
private function loadComplete(event:Event):void
{
cont.visible = true;
loadedClip.addEventListener("someEvent", function(){
trace("someEvent fired");
});
}
private function loadProgress(event:ProgressEvent):void
{
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
var progress:int=Math.round(percentLoaded * 100);
}
}
}
以上是关于ActionScript 3 装载机的主要内容,如果未能解决你的问题,请参考以下文章
ActionScript 3 装载机政策标志
ActionScript 3 装载机类
ActionScript 3 AS3装载机
ActionScript 3 装载机
ActionScript 3 最顶级的父装载机信息
ActionScript 3 AS3装载机垃圾收集