1 Reply Latest reply on Nov 18, 2009 3:52 AM by zeroskillz

    How can I load an external .swf into my stage pushing a button?

    Ermello_78 Level 1

      Hello...

      I have a problem...

      I have to add in a precise position into my stage another swf by pushing a button. Someone can help me?

      Thanks.

        • 1. Re: How can I load an external .swf into my stage pushing a button?
          zeroskillz Level 3

          using as3, assuming you have a button named 'myButton':

           

           

           

          var myLoader:Loader = new Loader(); // something to load the swf

           

          myButton.addEventListener(MouseEvent.CLICK, loadSWF); // listener for your button click

           

          function loadSWF(event:MouseEvent):void{

                // listener for when the load is finished

               myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, addSWF);

               // load the swf -- using your url of course

               myLoader.load(new URLRequest("yourSWFsURL.swf"));

          }

           

          function addSWF(event:Event):void{

               var mySwf = myLoader.content; // the thing the loader loaded

               mySwf.x = 100; // where you want it in the x

               mySwf.y = 100; // where you want it in the y

               addChild(mySwf); // add it to stage

          }

           

          HTH,

          -Ted