Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-28-2012, 02:34 AM   #1
MrTIMarshall
Registered User
 
Join Date: Mar 2012
Posts: 18
Default Having problems resizing external swf file

Hello,

I am loading a file into my movie clip in ActionScript 2 which is 1090 x 600. This is in proportion to the movie clip, of which it will be loaded in which is 716 x 394.

I have had help to get this far in the code below, however, although this works fine, the size does not and I do not understand how this function works...

ActionScript Code:
on (release) {     _root.mymc.holder_mc._lockroot = true;     _root.mymc._visible = true;     mcLoader = new MovieClipLoader();     mcLoader.loadClip("Female-Profile-02.swf", _root.mymc.holder_mc);         loading = new Object();     loading.onLoadInit = function(){         // resize here         _root.mymc.holder_mc._xscale = 100;         _root.mymc.holder_mc._yscale = 80;     }     mcLoader.addListener(loading); }

Thank you for any help and/or advice in advanced as I am grateful for your time and effort in replying to help me find a solution.

Best Regards,
Tim
MrTIMarshall is offline   Reply With Quote
Old 04-28-2012, 09:26 AM   #2
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

I figured it out, change your onLoadInit function to this:

ActionScript Code:
loading.onLoadInit = function(mc){         // resize here         onEnterFrame = function(){             trace(mc._width+" | "+mc._height);         }     }

and then retest your Movie, and observe the Output panel. You'll see that the size of the external SWF is changing all the time, this is because the SWF is not loaded inside your movieclip with its Flash dimensions, but rather with all its elements. So, if transitions make parts move out of the Stage, those will be visible, and thus extending the size, and when they're gone, the size of the external SWF will contract.

I found this solution on the internet:

Quote:
The problem here is that the loaded swf looses it's stage size when it's loaded into another swf. The stage of the parent becomes the stage of loaded swf. When requesting the size of the loaded swf, like you do, it will return the width and height of the entire surface of the first frame, not that of the stage.

The way I've solved this in the past is to create a movieclip instance on the first frame of the loaded swf with the size of the stage of that swf. Once the swf has been loaded you can then target that swf and get it's dimensions. Of course, this only works if you have publishing control over the swf you're trying to load.

To illustrate this in an example. In your swf to be loaded place a movieclip (e.g. a movieclip of a rectangle) on the first frame and name it stage_mc. When you now load the swf you can target that stage_mc instance like so:

ActionScript Code:
loadHandler.onLoadInit = function(mc:MovieClip) {     trace(mc.stage_mc._width + ", " + mc.stage_mc._height); }
__________________
I have returned, and am now 18
Prid is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:36 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.