dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: getting image height

  1. #1
    Vox adityadennis's Avatar
    Join Date
    Apr 2001
    Posts
    751

    getting image height

    I'm using this code to dynamically load an image:

    var loadit = new Loader();
    addChild(loadit);
    loadit.load(new URLRequest("images/project1.jpg"));

    and I'm trying to get the height and width of the loaded image. Does anyone know how to get these? I tried this:

    loadit.width

    but it didn't work.

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You have to first make sure the image is loaded.

    loadit.contentLoaderInfo.addEventListener(Event.CO MPLETE, completeHandler);
    function completeHandler(event:Event):void
    {
    var myImage:Bitmap=event.currentTarget.content as Bitmap;
    trace(myImage.height);
    }
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Vox adityadennis's Avatar
    Join Date
    Apr 2001
    Posts
    751
    It works! Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center