5 Replies Latest reply: Oct 4, 2012 8:57 AM by nikolaig RSS

    SWF Loader with variable loading?

    nikolaig Community Member

      I have my flash website composed from different labeled sections.

      One section (A) has SWF loader inside which different SWF's can be loaded depending on what image is clicked from a thumbnail image scroller.

      Here is the code for it:

       

      var xmlLoader:XMLLoader = new XMLLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/data.xml", {onComplete:_xmlCompleteHandler});

                                    xmlLoader.load();

                          //}

       

                           function _xmlCompleteHandler(event:LoaderEvent):void {

                                    _slides = [];

                                    var xml:XML = event.target.content; //the XMLLoader's "content" is the XML that was loaded.

                                    var imageList:XMLList = xml.image; //In the XML, we have <image /> nodes with all the info we need.

                                    //loop through each <image /> node and create a Slide object for each.

                                    for each (var image:XML in imageList) {

                                              _slides.push( new Slide(image.@name,

                                                                                                          image.@description,

                                                                                                          new ImageLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/thumbnails/appThmb_imgs/" + image.@name + ".jpg",

                                                                                                                                                  {

                                                                                                                                                            name:image.@na me + "Thumb",

                                                                                                                                                            width:_THUMB_W IDTH,

                                                                                                                                                            height:_THUMB_ HEIGHT,

                                                                                                                                                            //centerRegist ration:true,

                                                                                                                                                            //x:260, y:320,//doesn't work here but works in line 69

                                                                                                                                                            scaleMode:"pro portionalInside",

                                                                                                                                                            bgColor:0x0000 00,

                                                                                                                                                            estimatedBytes :13000,

                                                                                                                                                            onFail:_imageF ailHandler}),

                                                                                                          new SWFLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/images/" + image.@name + ".swf",

                                                                                                                                          {

                                                                                                                                                    name:image.@name + "Image",

                                                                                                                                                    width:_IMAGE_WIDTH,

                                                                                                                                                    height:_IMAGE_HEIGHT,

                                                                                                                                                    //centerRegistration:true,

                                                                                                                                                    x:-420, y:-260,

                                                                                                                                                    scaleMode:"proportionalInside",

                                                                                                                                                    bgColor:0x000000,

                                                                                                                                                    estimatedBytes:820000,

                                                                                                                                                    onFail:_imageFailHandler})

                                                                                                          )

                                                                            );

                                    }

       

      Is it possible to call up a specific SWF inside this SWFLoader from another section (B)

      For now all I can do is to make a link and bring a user to section (A) which always opens with the default (first in order) SWF.

      I want to have a number of image buttons in section (B) and each button would open a different SWF inside SWF loader in section (A)

      Is it possible to resolve?

       

      the code above also can be viewed at http://pastebin.com/JHNWvS6q

        • 1. Re: SWF Loader with variable loading?
          Ned Murphy CommunityMVP

          You can have your loaded swf file load other files into itself, but a loader can only load/hold one file at a time.  So you need other loaders if that's what you are asking about.

          • 2. Re: SWF Loader with variable loading?
            nikolaig Community Member

            Something like this is already happening in section (A). I have an xml loader which loads images externally into a scrolling thumbnail bar. Each image in this bar scripted to load different SWFs into the SWF loader. So loader loads various files one at a time, which is what I want.

            The problem is that I want to create a link from another section (B) into section (A) which will load another SWF into the loader once the section (B) opens. Once it opens the previously arranged functionality in section (A) takes over and different SWFs will be loaded into SWF loader from the scrolling thumbnail bar.

            Is this possible?

            • 3. Re: SWF Loader with variable loading?
              Ned Murphy CommunityMVP

              Chances are what you want is possible, but I lose track of your description of what you want when you mention "previously arranged functionality in section (A) takes over"

               

              If you have section A thumbs loading SWFs into an swfLoader object, and then you want section B thumbs to load into the same swfLoader, I see no reason why it couldn't happen.

               

              Maybe you should try to do what you want to do and then if you find you have a problem you can post that instead of posting a problem that is in the idea stages.  If you try it first you will have code to support your explanation of what isn't working.

              • 4. Re: SWF Loader with variable loading?
                nikolaig Community Member

                O.K. Thank you for the suggestion on how to best approach this issue.

                You understood me correctly, as you wrote:

                "If you have section A thumbs loading SWFs into an swfLoader object, and then you want section B thumbs to load into the same swfLoader, I see no reason why it couldn't happen."

                This is what I want. I will take a stab at it tomorrow morning and repost.

                Thank you

                • 5. Re: SWF Loader with variable loading?
                  nikolaig Community Member

                  O.K. here is my set up.

                  I have various buttons in section A. These buttons scripted to link user to section B with SWF loader where different SWF files load into SWF loader depending on which button was clicked from sectionA.

                  For that in section A I assigned a [AS3]var sourceVar_ProductsPopUps:String;[/AS3] and then each button has its unique [AS3] sourceVar_ProductsPopUps="myButton1-popup_tl.swf";[/AS3]

                  Then in the section B in the SWF loader I have specified [AS3]loaderProductPopUps = new SWFLoader(sourceVar_ProductsPopUps, [/AS3] where the value of "sourceVar_ProductsPopUps" allows to load mulitple SWFs from the section A.

                   

                  It works nice. The problem is that I want to remain in Section B and use the same SWF loader to load different SWF files.

                   

                  I have a working section B set up with XML loading and it works as well.

                  Here is the code part for the SWF loader in this way.

                  [AS3]new SWFLoader("loadingAssets/appThumbnails/slideshow_image scroller greenSock_mine/assets/images/" + image.@name + ".swf", [/AS3]

                  The reason why I have this different set up for SWF loader in section B is because I also have a thumbnail scroller at the bottom of the screen. When a user click on the thumbnail it brings a corresponding SWF in SWF loader.

                   

                  How would I combine the two?

                   

                  I would like to keep the functionality of section B and be able to load needed SWF from section A as well?