4 Replies Latest reply on May 24, 2010 6:16 AM by mlmadque

    HELP PLEASE - loading external swf scale problem

    mlmadque

      I have a Flex 3 Actionscript Project. Basically all it does it take some flash vars, set the sound volume,  and load an external swf using a loader and add the loader as a child. The problem is I want the loaded external swf to be scaled to fill the entire stage, even if it distorts it, and that doesn't seem to be happening.

       

      I really need to resolve this. ANY HELP APPRECIATED.

       

      Marcus

        • 1. Re: HELP PLEASE - loading external swf scale problem
          Flex harUI Adobe Employee

          What is happening, and what does your code look like?

          • 2. Re: HELP PLEASE - loading external swf scale problem
            mlmadque Level 1

            Thanks for the reply!

             

            Here's basically what my code looks like (note: I cut some stuff out that wasn't relevant for the sake of clarity).

             

            private var swfLoader:Loader = null;


            public function MySwfContainer()  

            {

                stage.scaleMode = StageScaleMode.EXACT_FIT;

                stage.align = StageAlign.TOP_LEFT;


                var request:URLRequest = new URLRequest(swfUrl);


                swfLoader = new Loader();

                swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,SWFLoader_Complete);

                swfLoader.load(request);       

            }


            private function SWFLoader_Complete(event:Event):void
            {

                addChild(swfLoader);

            }

             

            What I am observing is that if a swf larger than the stage area is loaded it clips it rather than scale it down and make it fit.

             

            Marcus

            • 3. Re: HELP PLEASE - loading external swf scale problem
              Flex harUI Adobe Employee

              I don't think StageScaleMode will work on a child SWF.  IIRC, the main SWF

              has a size given to it (500x375) unless you use metadata in your

              project and that is the dimensions that are scaled to fit.  Child content

              doesn't matter.  There is a scalemode post on my blog.

               

              You will have to set the scaleX/Y on the loader.

               

              --

              Alex Harui

              Flex SDK Team

              Adobe System, Inc.

              http://blogs.adobe.com/aharui

              • 4. Re: HELP PLEASE - loading external swf scale problem
                mlmadque Level 1

                Ok, I think I have this working as desired now.

                 

                I calculated the desired scaleX/scaleY based on the parent stage width/height and the child width/height. I then set the swfLoader scaleX/scaleY to these calculated values.

                 

                At first the scaleX/scaleY had no affect.

                 

                I finally figured out that I needed to set the stage scaleMode to NO_SCALE. Once I did that the scaleY and scaleY worked.

                 

                Thanks very much for the help.

                 

                Marcus