as3.0加载图片
package { import flash.display.MovieClip; import flash.net.URLRequest; import flash.display.Loader; import flash.events.MouseEvent; import flash.events.Event; import flash.display.SimpleButton; public class Main extends MovieClip { private var urlR:URLRequest; private var loader:Loader; private var emptyMc:MovieClip private var thisMc:MovieClip private var btn:SimpleButton private var arr:Array=["达闼","国广健康","泓图","人类遗传","首都医科大"] private var num:Number=0 public function Main(_thisMc:MovieClip,_btn:SimpleButton,_emptyMc:MovieClip) { emptyMc=_emptyMc btn=_btn thisMc=_thisMc btn.addEventListener(MouseEvent.CLICK,onBtn) urlR= new URLRequest(); } private function onBtn(e:MouseEvent){ loader=new Loader(); urlR.url = arr[num]+".jpg"; loader.load(urlR) loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeFun); num++ } private function completeFun(e:Event){ emptyMc.addChildAt(loader,emptyMc.numChildren) if(emptyMc.numChildren>=2){ emptyMc.removeChildAt(0) } trace(emptyMc.numChildren) } } }
posted on 2020-10-30 19:12 zqiang0803 阅读(181) 评论(0) 编辑 收藏 举报