Skip navigation
Currently Being Moderated

Scale external SWF

Jun 21, 2012 3:46 AM

Tags: #swfloader #scalemode

Hi!

 

I'm trying to load a Flex 4 SWF into the application, but I want that the external swf to fill all the application while maintaining the aspect ratio. The code is above:

 

ResizableSWF.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                 xmlns:mx="library://ns.adobe.com/flex/mx"
                                 xmlns:s="library://ns.adobe.com/flex/spark"
                                 addedToStage="onAddedToStage(event);"
                                 width="290"
                                 height="149"
                                 >
  
          <fx:Script>
                    <![CDATA[
  
                              private function onAddedToStage(event:Event):void {
  
                                        stage.scaleMode = StageScaleMode.SHOW_ALL;
                                        stage.align = StageAlign.TOP;
                                        this.width = stage.stageWidth;
                                        this.height = stage.stageHeight; 
  
                              }
  
                    ]]>
          </fx:Script>
  
          <s:BorderContainer id="borderContainer" 
                                                     cornerRadius="40">
  
                    <s:layout>
  
                              <s:VerticalLayout paddingTop="40"
                                                                        paddingLeft="40"
                                                                        paddingRight="40"
                                                                        paddingBottom="40"
                                                                        />
  
                    </s:layout>
  
                    <s:Label text="Label"/>
  
                    <s:HGroup>
  
                              <s:TextInput text="Input" />
  
                              <s:CheckBox label="CheckBox" />
  
                    </s:HGroup>
  
                    <s:Button label="Button"/>
  
          </s:BorderContainer>
  
</s:Application>

 

 

ScaleTest.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                 xmlns:mx="library://ns.adobe.com/flex/mx"
                                 xmlns:s="library://ns.adobe.com/flex/spark" 
                                 width="100%"
                                 height="100%"
                                 usePreloader="false"
                                 >
  
          <s:SWFLoader id="tretas" 
                                         width="100%"
                                         height="100%"
                                         autoLoad="true"
                                         scaleContent="true"
                                         verticalAlign="middle"
                                         horizontalAlign="center"
                                         source="ResizableSWF.swf"
                                         maintainAspectRatio="true"
                                         />
  
  
</s:Application>

 

 

When I run ResizableSWF and resize the window, the content is scale perfectly...

Sem Título.png

 

... but when I load it in ScaleTest, the content is also scaled when I resize the window, but it doesn't fill all the window.

Sem Título2.png

 

What am I doing wrong?

 

Thanks for the help!

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points