Skip to main content
June 10, 2011
Answered

Need to control scaling of a loaded swf when called from a container swf

  • June 10, 2011
  • 1 reply
  • 525 views

Flash Professional 11 (build 11.0.2.489)

Problem: When a swf is loaded into a container swf, the called swf scales to fill the window. When the stand alone swf is played from an HTML or SWF, it does not scale and displays correctly. I have tried adjusting the stage dimensions, publish settings,etc to no avail.

My container swf has a Movie Clip called contentContainer and three buttons. The buttons simply addChild(selected swf) and removes the current swf child.

Is there a way to control scaling for a swf loaded within another swf?

The relevent code after calling the load functions is as follows:

function onCompletePreloading():void
{
    contentContainer.addChild(_swfClipsArr[0]);


    IntroButton.addEventListener(MouseEvent.CLICK, setContent);
   
drilldownButton.addEventListener(MouseEvent.CLICK, setContent);
    EnterDatesButton.addEventListener(MouseEvent.CLICK, setContent);
}

function setContent(event:MouseEvent):void {
    var _swfToAdd:MovieClip;
    switch(event.target.name) {
        case "IntroButton":
        _swfToAdd = _swfClipsArr[0];
        break;     

        case "drilldownButton":
        _swfToAdd = _swfClipsArr[1];
        break;  

        case "EnterDatesButton":
        _swfToAdd = _swfClipsArr[2];
        break;
    }

    contentContainer.removeChildAt(contentContainer.numChildren-1);
    contentContainer.addChild(_swfToAdd);
    trace(_swfToAdd.customID);

}

This topic has been closed for replies.
Correct answer kglad

instead of using:

contentContainer.addChild(_swfToAdd);

use:

addChild(_swfToAdd);

or, if you were using that parent for some purpose:

var mc:MovieClip=new MovieClip();

mc.addChild(_swfToAdd);

1 reply

kglad
Community Expert
Community Expert
June 10, 2011

if contentContainer is transformed (including scaling), all its children (including that loaded swf) will be scaled.

you could reverse that scaling but it's a better idea to add that loader to the main timeline or a newly created (untransformed) parent.

June 11, 2011

kglad,

Setting contentContainer.scaleX and scaleX to 1 solved the problem. But if I understand you correctly, that is not the best way to solve it. Could you explain what you mean by "add that loader to the main timeline or a newly created (untransformed) parent'

Lakeman

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
June 11, 2011

instead of using:

contentContainer.addChild(_swfToAdd);

use:

addChild(_swfToAdd);

or, if you were using that parent for some purpose:

var mc:MovieClip=new MovieClip();

mc.addChild(_swfToAdd);