import flash.display.Loader; import flash.net.URLRequest; import flash.events.Event; import flash.display.Sprite; import flash.events.MouseEvent; var imageSprite:Sprite=new Sprite(); var len:int=arr_imageURL.length; for (var i:int=0; i<len; i++) { var url:String=arr_imageURL[i]; var imageLoader:Loader=new Loader(); //imageLoader.name=i; 这是以前的方法 imageSprite.addChild(imageLoader); imageLoader.load(new URLRequest(url)); imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,imageLoadedHandler,false,0,true); imageLoader.addEventListener(MouseEvent.CLICK,imageLoaderClickHandler,false,0,true); } function imageLoadedHandler(e:Event):void { var image:Loader=e.currentTarget.loader; image.width=100; image.height=100; } function imageLoaderClickHandler(e:MouseEvent):void { var image:DisplayObject=e.currentTarget as DisplayObject; var index:int=imageSprite.getChildIndex(image); //var index:int=int(image.name); 这是以前的方法 }