A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Getting height of Loaded SWF

  1. #1
    Member
    Join Date
    Nov 2000
    Posts
    92

    Getting height of Loaded SWF

    I'm using Flash MX 2004 and I'm trying to get the height of a movie I loaded into an empty movie clip. When I use trace to find out the height, it only displays the original height (0), and not the current height with the content loaded into the empty.

    I have this attached to a button on the main timeline:
    Code:
    on (release)	{
    	loadMovie("clip_content.swf", "empty_clip");
    	trace(empty_height);
    }
    and this variable initialization is on a "scripts" layer on the main timeline:
    Code:
    empty_height = empty_clip._height;
    Last edited by Aelo; 12-09-2004 at 09:32 AM.

  2. #2
    Senior Member
    Join Date
    Apr 2004
    Location
    Devon UK
    Posts
    240
    You are checking the property before the clip has time to load so you need to wait until the movie has finished loading.

    code:

    empty_clip.onLoad = function () {
    trace ("onLoad called");
    trace(empty_clip._height)

    }



    Try this snippet, you may need to add the correct target paths before it will work in your movie ie _root.empty_clip etc...

    Hope this helps...
    Select * From CLEVER_SIGNATURES

  3. #3
    The Flashman earl223's Avatar
    Join Date
    Sep 2000
    Location
    Marikina City, Philippines
    Posts
    876
    the probem may be in the fact that the even though you used loadMovie, the actual SWF may not have been FULLY loaded by the time you used TRACE. try to call the trace a few frames down the line. =)
    i eat actionscripts for breakfast

  4. #4
    Member
    Join Date
    Nov 2000
    Posts
    92
    wdhall, where were you suggesting I place the code you provided?

    I got it working by putting the empty_clip.onLoad code on the scripts layer (1st frame) and adding another frame to the movie (2 frames total) so it traces the initial height of the empty clip, 0, and then once I push the button, it updates with the new height.

    Only thing is, the Output window is being constantly updated. How do I do this so only after I've pushed the button, it updates?

    Note: I'd like to keep this on one frame if possible.
    Last edited by Aelo; 12-09-2004 at 10:34 AM.

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