3 Replies Latest reply on Apr 21, 2010 9:49 PM by Flex harUI

    How to calculate width of imported image

    SiHoop Level 1

      I use the code below to layout 12 imported images. The code works fine as long as the images have a consistent width. However, the widths have now changed and my layout is screwed up. To solve the problem I'd like to change my layout formula to place images according to thier widths. However, my problem is that I cannot access the widths of the imported images. So my question is: How can I calculate the width of each imported image?

       

            for(var i:int=0; i<12;i++){
                 imageLoader = new Loader();
                 var url:String = "images/animal"+i+".png";
                 var urlReq:URLRequest = new URLRequest(url);
                 var sprite:Sprite=new Sprite;

                 imageLoader.load(urlReq);
                 imageLoader.x=70*i
                 imageLoader.y=100
                 sprite.addChild(imageLoader)
                 addChild(sprite);
             }