2 Replies Latest reply on Sep 18, 2009 2:17 PM by 1powderpuffgrrl1FU

    AS3--loading swf on the stage with buttons

    1powderpuffgrrl1FU

      i wanted to make each button load an swf.How do I connect a button to loading a swf?

       

      contentButton1.addEventListener(MouseEvent.CLICK, N);

      function N(e:MouseEvent){

       

      var request:URLRequest = new URLRequest("N-Infant.swf");
      var loader:Loader = new Loader()
      loader.load(request);
      addChild(loader);
        • 1. Re: AS3--loading swf on the stage with buttons
          1powderpuffgrrl1FU Level 1

          oh and i want the first swf to replace the whole 2nd swf. no containers.

           

          i also tried this, but when i go to the 2nd swf, all the buttons in the swf that i switched over to stop working. each swf has the same actionscript for the tab buttons.

           

          // tab button

           

          var ldr:Loader = new Loader();
          var urlReq:URLRequest = new URLRequest("WEB1664_N-Infant.swf");

           


          contentButton1.addEventListener(MouseEvent.CLICK, weClick);
          function weClick (event:MouseEvent) {
          ldr.load(urlReq);
          addChild(ldr)
          }

           


          var ldr2:Loader = new Loader();
          var urlReq2:URLRequest = new URLRequest("WEB1664_L-Gradeschool.swf");

           


          contentButton2.addEventListener(MouseEvent.CLICK, weClick2);
          function weClick2 (event:MouseEvent) {
          ldr2.load(urlReq2);
          addChild(ldr2)
          }

          • 2. Re: AS3--loading swf on the stage with buttons
            1powderpuffgrrl1FU Level 1

            never mind i got it to work. yay!

            // tab button

            var ldr:Loader = new Loader();
            var urlReq:URLRequest = new URLRequest("WEB1664_N-Infant.swf");


            contentButton1.addEventListener(MouseEvent.CLICK, weClick);
            function weClick (event:MouseEvent) {
            ldr.load(urlReq);
            addChild(ldr)
            }