Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


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


    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
    var introImageHolder:MovieClip = new MovieClip();
      var j =new Loader();
      j.load(new URLRequest(imgUrl));
    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?



  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.

    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


  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


Copyright 1999 - 2012