2 Replies Latest reply: Oct 8, 2012 1:32 PM by nikolaig RSS

    2 vars for the same SWF Loader?

    nikolaig Community Member

      I can not figure out how to load different SWF files into the same SWF loader from different sections in my site. I have two sections "sectionA" and "sectionB". SectionB is the one where SWF loader is located.

       

      I figured out how to load different SWF files from "sectionA".

      I specify the var which I can use for any number of buttons:

      [AS]

      var sourceVar_ProductsPopUps:String;

      [/AS]

       

      Then I specify a function in each button using this var:

      [AS]

      myButton1.addEventListener(MouseEvent.CLICK, onClick_myButton1PopUp);

       

      function onClick_myButton1PopUp(event:MouseEvent):void {

                          sourceVar_ProductsPopUps="prdcts_popups/sumix1-popup_tl.swf";

                          gotoAndPlay("sectionB");

                          }

      [/AS]

       

      In sectionB, where SWF loader is located I use this code in SWF loader set up:

      [AS]

      loaderProductPopUps = new SWFLoader(sourceVar_ProductsPopUps,

      [/AS]

       

       

      Second step, where I get stuck is this - I want to have a thumb scroller in sectionB with images which act as buttons and reload additional different SWF files into the same SWF loader (so I don't have to constract a separate page for each image loaded)

      I tried to specify the same var in sectionB:

      [AS]

      var sourceVar_ProductsPopUps:String;

      [/AS]

       

      But as expected got a conflict in names.

       

      What can I use for two different vars in the same SWF loader? Is it some kind of if function or there is much more to it?

        • 1. Re: 2 vars for the same SWF Loader?
          Andrei1 Community Member

          What is SWFLoader? Where does this class coming from? Is it Flex SWFLoader?

          • 2. Re: 2 vars for the same SWF Loader?
            nikolaig Community Member

            Hi, thanks for answering my post.

            SWF loader comes from greensock.com platform

            Just in case here is full code for the loader which I have used:

             

            var loaderProductPopUps:SWFLoader;

             

            if (loaderProductPopUps){

            if(loaderProductPopUps.content){

               loaderProductPopUps.unload();

            }

            }

             

            loaderProductPopUps = new SWFLoader(sourceVar_ProductsPopUps, //the value of sourceVar_ProductsPopUps allows to load mulitple SWFs from the products page.

                                                                                                                {

                                                                                                                estimatedBytes:5000,

                                                                                                                container:holderMovieClip,// more convinient and easier to manage if to place the LoaderMax into an empty mc (holderMovieClip)

                                                                                                                                                                              // if not will work as well. Then the line container:holderMovieClip, has to be replaced with container:this,

                                                                                                                                                                              // can be any size, can not be scaled as it distorts the content

                                                                                                                onProgress:progressHandler,

                                                                                                                onComplete:completeHandler,

                                                                                                                centerRegistration:true,

                                                                                                                //x:-260, y:-320, //no need for this is if used: centerRegistration:true,

                                                                                                                alpha:1,

                                                                                                                scaleMode:"none",

                                                                                                                //scaleX:0, scaleY:0,

                                                                                                                //vAlign:"top",

                                                                                                                width:540,

                                                                                                                height:730,//scales proportionally but I need to cut off the edges

                                                                                                                crop:true,

                                                                                                                autoPlay:false

                                                                                                                });

             

             

            function progressHandler(event:LoaderEvent):void{

                      progressBarPopUp_mc.gradientbar_appLoader_mcPopUp_mc.scaleX = loaderProductPopUps.progress;

            }

             

             

            function completeHandler(event:LoaderEvent):void{

                      var loadedImage:ContentDisplay = event.target.content;

                      //TweenMax.to(loadedImage, 1.5, {alpha:1, scaleX:1, scaleY:1});//only need this line if corresponding values are changed in SWF loader constructor

                      TweenMax.to(progressBarPopUp_mc, 1.5, {alpha:0, scaleX:0.25, scaleY:0.25});

                      }

             

             

            loaderProductPopUps.load();