10 Replies Latest reply on Jul 21, 2009 12:29 PM by punknaught

    Loading External SWF - Problem

    Level 7

      Using MovieClipLoader I want to load external SWFs - and it is working fine
      if external swf doesn't have anything outside it's stage, otherwise it shows
      everything - that's the problem.

      For example, external swf's stage dimensions are 100x150, but it has some
      timeline animation (some objects scrolling through the stage, some bouncing
      text animation that sometimes goes off-stage, etc..).

      So when I load this external movie (banner.swf), I can see all these objects
      that were bouncing outside this 100x150 area (the stage of banner). Even
      more - the size of loaded movie is larger than 100x150px (because of these
      off-stage objects that are now visible). This way I'm getting positioning
      problems, too.

      var mcl:MovieClipLoader = new MovieClipLoader();
      mcl.loadClip("banner.swf", holder);

      holder._x = Stage.width/2 - holder._width/2;
      holder._y = Stage.height/2 - holder._height/2;

      Thanks in advance,

        • 1. Re: Loading External SWF - Problem
          kglad Adobe Community Professional & MVP
          create an empty 1st keyframe in your external swf and mask the stage.
          • 2. Re: Loading External SWF - Problem
            riquigley Level 2

            I'm having this exact same problem.  I'm creating a gallery of about 30 student made swf animations.  I'm trying to create a flash app that will load the external swf's and display them on the stage.


            I make a mask that dynamically changes depending on the size of the loaded swf (loader.width, loader.height),  but flash gives me the width and height values based on the dimensions of all the graphics on the first frame, and not the height and width of the external swf's stage.  If there was simply a way to get the stageHeight and stageWidth of the external file when it loads, then all would be right with the world.


            Anybody know a way to do this?

            • 3. Re: Loading External SWF - Problem
              kglad Adobe Community Professional & MVP

              if all the swfs are as2 swfs you must loop through all the frames of the external swf (not displaying this to the user) updating the main timelines width/height to make sure you have the max width/height that will be displayed.  you can then return to frame 1 of the external swf and display it to the user.

              • 4. Re: Loading External SWF - Problem
                freddy rios

                Hi kglad,


                Does doing that takes only into account width and height of the stage, or also considers off stage items (as in the initial question)?


                I am also looking at this issue and we can't have all the content providers modify their pre-existing flash applications to be displayed in the appropiate scale. We are looking to any of the following:


                • find a way to get adobe air/flash to not consider the off stage elements on the width/height we set to the movie.
                • find a way to get the stage size from the external movie and use that to auto calculate the resize needed.
                • any other alternative that allows to have the same end result, which is loading up the external content at the size we specify and displaying well. We can actually hide content outside the stage, but we still need to know the appropiate scale / size to apply to the movie so what's visible matches the are where we want to show the content.
                • 5. Re: Loading External SWF - Problem
                  kglad Adobe Community Professional & MVP

                  you will detect off-stage items in the external swf.


                  if you have not control of the external swfs and no way to enforce some common actionscript to the external swfs, there's no way, during runtime, you can reliably determine the fla stage size setting used to publish the swf.

                  • 6. Re: Loading External SWF - Problem
                    freddy rios Level 1

                    I didn't notice before this was posted in AS 1/2.


                    We found a way to get it working on our air app. It's using flash.display.loader and its working effectively with the external swf we have tried it - both with files that have the off stage issue and files that don't..


                    var fullWidth:Number = loader.content.width;

                    var fullHeight:Number = loader.content.height;

                    var stageWidth:Number = loader.content.loaderInfo.width;

                    var stageHeight:Number = loader.content.loaderInfo.height;

                    var fixOffStageScaleX = fullWidth / stageWidth;

                    var fixOffStageScaleY = fullHeight / stageHeight;


                    kglad, is that a new feature/behavior or do u know of any issue with it?


                    Ps. We will certainly be looking at how it behaves with plenty of more content as we have an ongoing private beta.

                    • 7. Re: Loading External SWF - Problem
                      kglad Adobe Community Professional & MVP

                      in as3 this issue was solved (as you found) by the stage.stageWidth and stage.stageHeight properties.  it works not only for air files but also non-air swf files.

                      • 8. Re: Loading External SWF - Problem
                        freddy rios Level 1

                        Ok, there isn't much Correct information regarding it though.


                        Carefull, as we are not using stage.stageWidth as that doesn't helps at all i.e.


                        loader.content.widthxheight: 1010.95x777.5

                        loader.content.loaderInfo.widthxheight: 864x576

                        loader.content.stage.stageWidhtxHeight: 1440x900

                        loader.stage.stageWidhtxHeight: 1440x900


                        Remember that regardless of scale mode (mentioned on the doc), .stage refers to the main movie's stage, so there is no chance .stage.stageWidth will ever give u info on the external movie.

                        • 9. Re: Loading External SWF - Problem


                          NEED HELP. THANK YOU.

                          • 10. Re: Loading External SWF - Problem

                            Was there any conclusive fix to this problem?  I am having the exact same issue.  I attempted what kglad said and applied a mask to the stage, but that did not seem to work.  I am loading a movie from flash cs4 using 3d transition (parallax) into an actionscript project i am building in flex builder 3.  Since the objects are required to be scaled up after pushing them back on the z axis they spill out of the stage onto the screen.  Could someone tell me what worked?  Thank you in andvance.