The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 4 of 4

Thread: can't get height of image inside an mc

  1. #1

    can't get height of image inside an mc

    HI

    I am trying to get at the properties (eg height) of an jpeg that I have loaded into a movieclip at runtime. Here's the code
    Code:
     
    var introImageHolder:MovieClip = new MovieClip();
    :
    :
      var j =new Loader();
      j.load(new URLRequest(imgUrl));
      introImageHolder.addChild(j)
      introImageHolder.x=245;
      introImageHolder.y=108;
    Sadly whilst the image loads correctly if I try
    trace (introImageHolder.height) I get 0, which is odd - I would have thought that the mc would take on the size of its contents, but I guess I am missing something! Also trace (introImageHolder.j.height) throws errors

    How do I get at the height of the image please?

    Thanks

    E

  2. #2
    You have to wait until the image loads. Even if it takes just a split second, it still hasn't loaded at the time you run the code following the load method. You have to use an event listener.

    Code:
    j.contentLoaderInfo.addEventListener(Event.COMPLETE, methodToAccessImageHeight);

  3. #3
    Ah yes, that makes sense!

    Should have tought of it - works fine now!

    Thanks for the reply

    E

  4. #4

    cant get height of image inside an mc

    thank you very much for the help.If image1 is a MovieClip, how would the code change?Also, how does it change if the Mc does not exist in the library, but is created when compiling? ex bitmaps added as children to an empty mcthanks a lot

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012