ActionScript 3 带有圆形预加载器微调器的AS3 Image Loader

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 带有圆形预加载器微调器的AS3 Image Loader相关的知识,希望对你有一定的参考价值。

import caurina.transitions.Tweener; // don't forget to install this.

function loadImageTo(which_mc:MovieClip, whichImg:String, finishFunction:Function):void // syntax: loadImageTo("which movieclip to add the image to", "the path/URL to the image", "the function to call when complete")
{
	var imageLoader:Loader = new Loader();
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishFunction);
	which_mc.addChild(imageLoader);
	try {
		imageLoader.load(new URLRequest(whichImg));
	} catch (error:IOErrorEvent) {
		// ouch! an error
	} catch (error:Error) {
		// ouch! an error
	}
}

function hideSpinner1(e):void // you should totally customize this function
{
	Tweener.addTween(spinner_mc, {alpha:0, time:.5, onComplete:function(){ spinner_mc.enabled = false; } }); // keep this line in here, to hide the spinner.

	// resize your new image:
	holder_mc.width = stage.stageWidth;
	holder_mc.height = stage.stageHeight;
	
	// apply smoothing to your new image:
	var img_bm:Bitmap = new Bitmap();
	img_bm = Bitmap(e.currentTarget.content);
	img_bm.smoothing = true;	
}

function init()
{
	if (holder_mc.numChildren > 0) holder_mc.removeChildAt(0); // this line is added so that any previously-loaded image is removed before adding another to the holder
	loadImageTo(holder_mc, "sample.jpg", hideSpinner1); // if you want to use the loadImageTo function without a preloader spinner, just create an empty function and send that as the "finishFunction"
}

init(); // make it so.

以上是关于ActionScript 3 带有圆形预加载器微调器的AS3 Image Loader的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 预加载器和进度结构

ActionScript 3 AS3预加载器

ActionScript 3 AS3:预加载器

ActionScript 3 绘制圆预加载器

ActionScript 3 AS3:预加载器代码

ActionScript 3 Oman3D - 简单预加载器