1 Reply Latest reply on Feb 2, 2010 10:32 PM by kglad

    Loading External swf's

    DJ Foosh

      I have created buttons with this Actionscript.  They load in the external swf's fine, but when I click on them again they load them in again, and again, and again...  What do I need to write in the code so it loads in fresh everytime you click on the button? (or in other words, cleans up the load in page before it loads in new files). 

       

      var myLoader:Loader=new Loader();

       

      rates_btn.addEventListener(MouseEvent.CLICK, rates);

      function rates(myevent:MouseEvent):void {

      var myURL:URLRequest=new URLRequest("fooshrates.swf");

      myLoader.load(myURL);

      myLoader.x = 15

      myLoader.y = 15

      addChild(myLoader);

      }

       

       

      contact_btn.addEventListener(MouseEvent.CLICK, contact);

      function contact(myevent:MouseEvent):void {

      var myURL:URLRequest=new URLRequest("contact.swf");

      myLoader.load(myURL);

      myLoader.x = 15

      myLoader.y = 15

      addChild(myLoader);

      }

       

      testimony_btn.addEventListener(MouseEvent.CLICK, testimony);

      function testimony(myevent:MouseEvent):void {

      var myURL:URLRequest=new URLRequest("fooText.swf");

      myLoader.load(myURL);

      myLoader.x = 535

      myLoader.y = 0

      addChild(myLoader);

      }