3 Replies Latest reply on Oct 25, 2007 4:50 PM by NoNicknameThanks

    SWF content scaling

    NoNicknameThanks
      Hey all.

      I really hope this question isn't noob, because I feel like I'm missing something small.

      I have created an Actionscript 3 SWF file with Flash that is 800x300. There are objects outside of the workspace boundaries of my Flash SWF... and I'm using a SWFloader component in FLEX to display my SWF. I have scale content set to True, and I tried messing with the contentWidth and contentHeight values but maybe I'm just to noob to understand why objects on the SWF are showing up outside the 800x300 boundaries.

      Can anyone help me out with this? :/

      In short, I'm trying to display a SWF to be exactly 800x300 and show nothing outside of that space. I even tried putting it inside of a canvas component and that was also no good.

      Thanks for any advice!

      -Steve
        • 1. Re: SWF content scaling
          JabbyPandaUA Level 3
          No your question is not noob, I was puzzled about the same issue several days ago.

          This behavior of SWFLoader is pretty annoying for anyone who is coming into Flex development from Flash world.

          Have a look here:
          http://www.actionscript.org/forums/showthread.php3?p=662022

          I am currently using mask together with SWFLoader to cut anything outside the borders of actual Stage inside SWF file.

          I am calling this function after my external SWF file is full loaded:

          private function swfComplete() : void {
          var s:Shape = new Shape();
          s.graphics.beginFill(0xFFFFFF);
          s.graphics.drawRect(0, 0, swf.content.loaderInfo.width, swf.content.loaderInfo.height);
          s.graphics.endFill();
          swf.addChild(s);
          s.visible = false;
          swf.mask = s;
          }

          ....
          <mx:SWFLoader id="swf" source="balls.swf" complete="swfComplete()">
          </mx:SWFLoader>
          • 2. Re: SWF content scaling
            Karl_Sigiscar_1971 Level 3

            What we did in our application is:

            - Use the Flex component kit for Flash CS3 in order to create a Flex component from the Flash piece
            - Make the resulting SWC part of the project by linking to it in the Flex project properties
            - Instantiate it in the Main MXML file

            Quoting the documentation for the Flex component kit for Flash CS3:

            Adding a bounding box to a Flash component

            You might add animations or other effects to your Flash component that change its size at run
            time. By default, Flex sets the size of a Flash component at run time to its actual size.
            Therefore, when your component changes size, Flex must update the layout of your
            application; otherwise, the new size of your component might cause it to overlap other
            components.

            One way to control the size of a Flash component is to add a bounding box to the
            component. The bounding box is a MovieClip instance that Flex uses to size the Flash
            component at run time. Within the area of the bounding box, the Flash component can
            perform animations or modify its visual characteristics.

            >> Download, install and check the documentation of the Flex component kit for Flash CS3:
            http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1273 018

            • 3. Re: SWF content scaling
              NoNicknameThanks Level 1
              Thanks for the help, guys!

              That mask code is a good workaround for what I was doing, and I had no idea there was a component kit for Flash CS3. I'm downloading it now. :)