Getting the height of a dynamically loaded movie

Posted on 2007-07-26
Last Modified: 2013-11-12
I have a flash movie that loads images from an xml document into a movie clip. I am placing the images at a specified interval but I want their to be able to have different sized images with the same spacing between them.
I was going to do this by dynamically figuring out (starting at 0) where to place the next clip with something like:

var interval = 20;
var currentheight = 0;
for (i=0;i<n;i++)
   var currentThumb_mc = scroller.createEmptyMovieClip("thumbnail_mc"+i,i);
   currentThumb_mc._y = currentheight;

   currentheight = currentheight + currentThumb_mc._height + interval;

However currentThumb_mc._height is always zero. After loading the image in the movie should have a size shouldn't it?

So I guess what I am looking for is how to get the height of a loaded movie.


Question by:jrm213jrm213
    LVL 22

    Accepted Solution

    you do not have access tothe movieclip properties until it is fully loaded...

    so to I would use the MovieClipLoader class to set the values...  in the onLoadInit() method, is where you would use this line  currentheight = currentheight + currentThumb_mc._height + interval;

    and here is a link to a nice tutorial about the movieclip loader class:

    LVL 17

    Author Comment


    This is my first time ever using Flash and I kind of figured that was the case but was hoping that it wasn't. I am guessing that there is no guarantee that the movie will load before my code starts loading the next one and I need the height increase before that to determine where to place the next clip.

    I ended up placing the height into the xml. It is another step in the process and prone to human error but it is what it is I guess.

    Thanks for the info and the link to the article.
    LVL 22

    Expert Comment


    actually because of latency, you will almost never have the value of the ready to be used when you use loadMovie, even when the files are on your local desktop.

    let me know if you need help with the MovieClipLoader class.


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now