错误#2044:未处理的IOErrorEvent:当LOOPED时,但显示正确

时间:2014-04-21 08:33:59

标签: actionscript-3 flash

我试图在循环中从服务器加载图像,它可能没有图像或最多3张图像。通过URLRequest加载图像。

不太确定如何正确地将它放入循环中,它给我两次错误2044然后它正确显示图像。感谢您的时间和帮助!

for (var j:int = 5; j < somedata.length; j++) 
            {
                var myLoader:Loader = new Loader();
                var image:Bitmap;
                var url:URLRequest = new URLRequest("http://www.rentaid.info/rent/"+somedata[j]);
                myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
                myLoader.load(url);




                function onImageLoaded(e:Event):void {
                image = new Bitmap(e.target.content.bitmapData);

                var mw:Number = bf.width*2;
                var mh:Number = bf.height*1.2;   
                    image.y = bf4.y+25;
      /* if you set width and height image same with the stage use this */
                image.width = mw;
                image.height = mh;
                addChild(image);

                }
            }

编辑:

for (var j:int = 5; j < somedata.length; j++) 
            {
                if(somedata[j]==! null){
                var myLoader:Loader = new Loader();
                var image:Bitmap;
                var url:URLRequest = new URLRequest("http://www.rentaid.info/rent/"+somedata[j]);
                myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
                myLoader.load(url);




                function onImageLoaded(e:Event):void {
                image = new Bitmap(e.target.content.bitmapData);

                var mw:Number = bf.width*2;
                var mh:Number = bf.height*1.2;   
                    image.y = bf4.y+25;
      /* if you set width and height image same with the stage use this */
                image.width = mw;
                image.height = mh;
                addChild(image);

                }
            }
            }

0 个答案:

没有答案