0 Replies Latest reply on Mar 14, 2011 6:43 PM by j7a7s7o7n

    External SWF Unload itself and Load a new one from a button within itself?

    j7a7s7o7n

      Ok, I've got a website that consists of a Main SWF with six navigation buttons that load and unload External SWF pages.

       

      Everything works perfect except for one problem I just can't figure out. On the homepage, called "home_page_swf", I have three buttons at the end of three paragraphs that say "Learn More" and need them to trigger the "home_page_swf" to unload itself and replace it with one of the other external swf pages. I basically want the three buttons within the "home_page_swf" to perform the same function as the "Services", "Portfolio", and "Team" buttons that are located in main swf.

       

      I've been trying to read up on it and I keep finding something about "Dispatch Event" but can't figure out how to apply it to the code I am using for the website I'm working on. I'll post the code below for the main navigation swf and what the labels are for the buttons that are inside the external swf called "home_page_swf". If anyone could help answer me figure this out I'd be very grateful.

       

      Main SWF with main navigation buttons:

       

      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_NODOORS.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.CLI CK, btnClick);
      services_page_swf.addEventListener(MouseEvent.CLIC K, btnClick);
      about_page_swf.addEventListener(MouseEvent.CLICK, btnClick);
      team_page_swf.addEventListener(MouseEvent.CLICK, btnClick);
      contact_page_swf.addEventListener(MouseEvent.CLICK , btnClick);

       

      On the external "home_page_swf" there are three buttons that are labeled:

       

      services_page_swf

      portfolio_page_swf

      team_page_swf

       

      I need them to unload the external swf that they are on and replace itself onto the main SWF with pages that they reference. This way when the new SWF is loaded the navigation buttons on the main swf would still work like normal.