3 Replies Latest reply on Dec 21, 2010 4:31 AM by Ned Murphy

    Problem with loading external swf from within an external swf...

    j7a7s7o7n

      Ok, everything was going fine on a website project I've been working on, until yesterday. I'll try to explain the whole scenario first, and I'll put the code in here too so anyone can try to figure out what is wrong. Here's the breakdown of the site:

       

      1) There is a MAIN SWF file that plays an intro and then stops on the last frame with the "Main" Navigation buttons.

       

      2) Inside the Root folder where the MAIN SWF resides, there is another folder called "swfs" which contains six main external navigation pages, as well as another folder called "galleries" which contains additional external swf files for six gallery pages.

       

      3) On one of the layers of the MAIN SWF, there is a movie clip called "mySWFLoadingClip" that the "Main" Navigation buttons load and unload the external  swf pages onto. These all work perfectly. The problem start on the next step. This is the code I used for the navigation buttons on the MAIN SWF timeline:

       

      var Xpos:Number = 0.0;
      var Ypos:Number = 0.0;
      var swf:MovieClip;
      var loader:Loader = new Loader();

       

      var defaultSWF:URLRequest = new URLRequest("swfs/home_page_swf.swf");

       

      loader.load(defaultSWF);
      loader.x = Xpos;
      loader.y = Ypos;
      this.mySWFLoadingClip.addChild(loader);
      ////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////

       

      // Btns Universal function
      function btnClick(event:MouseEvent):void {

       

      this.mySWFLoadingClip.removeChild(loader);
      var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
      loader.load(newSWFRequest);
      loader.x = Xpos;
      loader.y = Ypos;
      this.mySWFLoadingClip.addChild(loader);
      }
      // Btn listeners
      home_page_swf.addEventListener(MouseEvent.CLICK, btnClick);
      portfolio_page_swf.addEventListener(MouseEvent.CLICK, btnClick);
      services_page_swf.addEventListener(MouseEvent.CLICK, btnClick);
      about_page_swf.addEventListener(MouseEvent.CLICK, btnClick);
      team_page_swf.addEventListener(MouseEvent.CLICK, btnClick);
      contact_page_swf.addEventListener(MouseEvent.CLICK, btnClick);

       


      4) One of the external navigation SWF pages is called "portfolio_page_swf" and gets loaded into the "mySWFLoadingClip" moveclip on the MAIN SWF. This is where the problem begins. The "portfolio_page_swf" has six buttons that call out to an additional external swf from the galleries folder. Now when I open the "portfolio_page_swf" file to test out if the buttons work, they work perfect. When I click the buttons, the external swf gallery files show up like they should. But the problem is that when I open the "MAIN SWF" file to test out the site, I can click the Main Navigation buttons and they work. I click on the Portfolio button on the Main SWF time line, and it places the "portfolio_page_swf" onto the stage like it should, but when I click the buttons that are within the "portfolio_page_swf" the galleries don't show up. The buttons from the "portfolio_page_swf" page only work if I open the "portfolio_page_swf" file directly. Here is the code that is used in the "portfolio_page_swf":

       

      var Xpos:Number= 0.0;
      var Ypos:Number = 0.0;
      var swf:MovieClip;
      var loader:Loader = new Loader();

       

      var defaultSWF:URLRequest = new URLRequest("galleries/gallery_print_swf.swf");

       

      loader.load(defaultSWF);
      loader.x = Xpos;
      loader.y = Ypos;
      this.mySWFLoadingClipGALLERY.addChild(loader);
      ////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////

       

      // Btns Universal function
      function btnClick(event:MouseEvent):void {

       

      this.mySWFLoadingClipGALLERY.removeChild(loader);
      var newSWFRequest:URLRequest = new URLRequest("galleries/" + event.target.name + ".swf");
      loader.load(newSWFRequest);
      loader.x = Xpos;
      loader.y = Ypos;
      this.mySWFLoadingClipGALLERY.addChild(loader);
      }
      // Btn listeners
      gallery_print_swf.addEventListener(MouseEvent.CLICK, btnClick);
      gallery_packaging_swf.addEventListener(MouseEvent.CLICK, btnClick);
      gallery_web_swf.addEventListener(MouseEvent.CLICK, btnClick);
      gallery_video_swf.addEventListener(MouseEvent.CLICK, btnClick);
      gallery_others_swf.addEventListener(MouseEvent.CLICK, btnClick);
      gallery_logos_swf.addEventListener(MouseEvent.CLICK, btnClick);

       

       

       

       

       

      If anyone can help me figure this out I would be really grateful. This is a very important project and the deadline is coming up very soon. Please help me figure out how to load an External SWF onto the main time line and then load an additional external swf from within the first external swf. I'm stumped.