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?


      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.x = Xpos;
      loader.y = Ypos;
      ////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////

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

      var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
      loader.x = Xpos;
      loader.y = Ypos;
      // 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:






      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.