apache-flexflex3resizecanvasswfloader

resize loaded SWF to fit in canvas


a .fla is 500 x 300. Inside, content moves OUT of the 500 x 300 stage so that it appears like it hides or moves off of the screen.

.fla complied... loaded into Flex via SWFLoader:

<mx:Conainer width="500" height="300">
       <mx:SWFLoader width="100%" height="100%" />
</mx:Conainer>

Loaded .swf file shows outside of the 500 x 300 Container in Flex.

How can i get it so that only what is INSIDE of the Container is visible?


Solution

  • Ok, i figured it out.

    <mx:Canvas id="swfHolder" mask="{maskCanvas}">
            <mx:SWFLoader id="swffer" scaleContent="true" />
    </mx:Canvas>
    
    <mx:Canvas id="maskCanvas" backgroundColor="#000000"/>
    

    The trick is to use the "mask" property. Note the object doing the "masking" must have a backgroundColor property set. I found this article helpful: link text