4
votes

I have an application where I try to load an external SWF. So, we have:

  • My application: The Stage's dimensions are 768x1280. ScaleMode = EXACT_FIT.
  • External SWF: It's another application where its stage is: 800x600. ScaleMode = EXACT_FIT.

The problem is that the external SWF does not modify its size although I apply "scaleX, scaleY", change its width and so on. I also tried to insert it into a Canvas container (as "How to resize an external SWF to fit into a container?" ) but it didn't solve my problem. The interesting piece of code is when the external SWF is loaded by my application:

private function onLoadedApp( evt:Event ):void{ 
     stage.scaleMode = StageScaleMode.EXACT_FIT;    
     trace("Loading Application..");           
     var loaderInfo:LoaderInfo = evt.target as LoaderInfo;    
     loaderInfo.removeEventListener( Event.COMPLETE, onLoadedApp);   
     trace(loaderInfo.loader.content);           
     var swfApplication:SpriteUIComponent = new SpriteUIComponent(evt.target.loader.content );           
     if( SWFContainer.width < swfApplication.explicitWidth ){               
            var coef:Number = SWFContainer.width/swfApplication.explicitWidth;  
            swfApplication.scaleX = coef; 
            swfApplication.scaleY = swfApplication.scaleX;            
      }                
       SWFContainer.addElement(swfApplication);
}

I also tried to do it through SWFLoader, but the external.swf's content doesn't change its original size although I add the "scaleContent" parameter.

Visual results I got:

The external SWF is loaded on the suitable position and it "seems" to have 320x240 dim. But its width is a bit cropped, since if I stretch the Flash Player I achieve to see the rest of the external swf's stage. Besides, the external SWF never is resized although I shrink/stretch the Flash Player. It always remains fixed (if I trace its dimensions, I always get 800x600, although I visually see 320x240)- If I increase the stage's width of the main application, this little clip dissapear.

Discussion:

I know the original Stage's dimensions are 800, and this is greater than the original stage of my application (768), but I think, when I do the resizing, external SWF's Stage have to be fitted in the container. It is fitted, but a part of the external SWF is not seen. It's like Flash Player remembered that the external SWF Stage's width were greater than my application's one...

Thanks in advance.

3
I've just changed the description with a piece of code. Thanks.Manel
Hi! Did you find a solution of the problem? I am currently having exactly the same issue:)Jacek Francuz

3 Answers

0
votes

Even with scaleContent set to "true" you still need to set an exact height and width to the SWFLoader control for it to even try resizing the internal SWF. All scaleContent does is instead of showing the SWF at regular or stretched sizes, it also up-scales the SWF if needed, and if not just scales it to retain the ratio of the original SWF.

0
votes

I don't think the issue is with your ScaleMode. There can only be one Stage per flash player. The "stage" property of your 'external' SWF references the Stage of your 'application' SWF after it's added to the display list. If the SWF is loaded and not added to the display list, the loaded SWF's 'stage' property will equal 'null'. Setting the stage scaleMode inside your external SWF won't dictate how it scales once loaded into another SWF.

Also, you're probably resizing the SWFContainer, not the SWF itself...thats why the SWF width and height properties are always 800x600. I'm not sure if this is what you're asking for, but from what I'm understanding, you may need to create a stage resize event listener.

0
votes

Have you tried to use a scale effect on "External SWF"?

Scale Effect