ActionScript 3 AS3:使用加载程序进行SWF,JPEG,GIF和PNG

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 AS3:使用加载程序进行SWF,JPEG,GIF和PNG相关的知识,希望对你有一定的参考价值。

/********************************
Event Listeners
********************************/
var imgLoader:Loader = new Loader();
	initBasicListeners( imgLoader );
	imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler, false, 0, true);
	imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler, false, 0, true);
	imgLoader.load(new URLRequest(asset));

//These Event Listeners are used a lot so let's try to minimize redundancies
function initBasicListeners(dispatcher:IEventDispatcher):void
{
	dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler, false, 0, true);
	dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler, false, 0, true);	
	dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
}

/********************************
Event Handlers
********************************/
function httpStatusHandler (e:Event):void
{
	//trace("httpStatusHandler:" + e);
}
function securityErrorHandler (e:Event):void
{
	trace("securityErrorHandler:" + e);
}
function ioErrorHandler(e:Event):void
{
	trace("ioErrorHandler: " + e);
}
function progressHandler(e:Event):void
{
	trace(e.currentTarget.bytesLoaded + " / " + e.currentTarget.bytesTotal);
}

function onCompleteHandler (e:Event):void
{
	trace("imgCompleteHandler:" + e.currentTarget.content + " "  + e.currentTarget.loader);
	addChild( e.currentTarget.loader );
}

以上是关于ActionScript 3 AS3:使用加载程序进行SWF,JPEG,GIF和PNG的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 AS3:图像加载

ActionScript 3 AS3预加载器

ActionScript 3 AS3:XML加载

ActionScript 3 AS3加载Txt

ActionScript 3 AS3:预加载器

ActionScript 3 AS3:加载XML