as3.0加载图片,设置不失真
package com{ import flash.display.MovieClip; import flash.net.URLRequest; import flash.display.Loader; import flash.events.MouseEvent; import flash.events.Event; import flash.display.SimpleButton; import flash.display.Bitmap; public class LoaderJPG extends MovieClip { public static var urlR:URLRequest; public static var loader:Loader; public static var emptyMc:MovieClip; public static var thisMc:MovieClip; public function LoaderJPG(_thisMc:MovieClip,_emptyMc:MovieClip) { emptyMc = _emptyMc; thisMc = _thisMc; urlR= new URLRequest(); } public static function addJPG(jpgName:String) { loader=new Loader(); urlR.url = "JPG/"+jpgName + ".png"; loader.load(urlR); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeFun); } public static function completeFun(e:Event) { //emptyMc.addChildAt(loader,emptyMc.numChildren); emptyMc.addChildAt(new Bitmap(e.target.loader.content["bitmapData"],"auto",true),emptyMc.numChildren); if (emptyMc.numChildren >= 2) { emptyMc.removeChildAt(0); } //trace(emptyMc.numChildren); } } }
posted on 2021-05-24 16:31 zqiang0803 阅读(115) 评论(0) 编辑 收藏 举报