flash as3加载外部swf图片,loading

//这个例子是加载外部的文件,注意load方法只能接受URLRequest文件
var request:URLRequest = new URLRequest("index.swf");
//定义一个loader
var loader:Loader = new Loader();
//为加载过程建立事件侦听器
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
//加载完成的事件侦听器;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
//加载过程中执行;
function loadProgress(event:ProgressEvent):void
{
	var percentLoaded:Number = event.bytesLoaded / event.bytesTotal;
	percentLoaded=Math.round(percentLoaded*100);
	trace("Loading: "+percentLoaded+"%");
	txt.text = "加载中: " + percentLoaded + "%" + "已完成";
}
//加载完成后执行
function loadComplete(event:Event):void
{
	trace("Complete");

	//改变宽高并放置在场景中

	loader.width = 1100;
	loader.height = 750;
	loader.scaleX = 1.17;
	loader.scaleY = 1.17;
	stage.addChild(loader);

}
//载入
loader.load(request);
 

你可能感兴趣的:(Flash)