1 2 Previous Next 46 Replies Latest reply on Aug 26, 2011 3:41 PM by [no name] :D 2011

    How to import SWF to stage???

    [no name] :D 2011

      Hello everyone

       

      I have been trying to import a SWF file to the timeline but when I do its a white box, and even when I import to library..same thing, its a white box..Can someone help me??

        • 1. Re: How to import SWF to stage???
          kglad Adobe Community Professional & MVP

          don't import it, load it.

           

          in as2, use the movieclip loadMovie() method.  in as3, use the loader class.

          1 person found this helpful
          • 2. Re: How to import SWF to stage???
            [no name] :D 2011 Level 1

            Thanks it worked..but it plays immediately when I publish as SWF. I want it in only one frame so I can link a button in a previous frame to that frame using "click to go to frame and play". Can you help me with this?

            • 3. Re: How to import SWF to stage???
              kglad Adobe Community Professional & MVP

              if you have the fla that published that external swf that you load, you can add a stop() to the first frame actions panel.  otherwise, the coding is more complex and i'll need to know whether your main (loading) swf uses as2 or as3.

              1 person found this helpful
              • 4. Re: How to import SWF to stage???
                [no name] :D 2011 Level 1

                I added stop(); to the fla and republished as SWF and reloaded it in my main fla, linked it and tried it. but when i do click on the button (which I coded with "click to go to frame and play") the swf file appears but its not moving, its still. btw i'm using as3

                • 5. Re: How to import SWF to stage???
                  kglad Adobe Community Professional & MVP

                  if you're trying to open your loaded swf to a particular frame, you have some non-trivial coding to do.

                   

                  copy and paste the code you're using to load your swf and direct it to a particular frame.

                  • 6. Re: How to import SWF to stage???
                    [no name] :D 2011 Level 1

                    That is what I done, I directed the code to frame 13 and a button from frame 1 was linked to frame 13 by the code snippet "click to go to frame and play". and when you say "copy and paste it"..from where did you mean?  You know how you told me to stop (); the swf im trying to load, wouldn't that be the reason why it ain't moving? but then again I don't want it to start moving immediately in my main project. im confused.

                    • 7. Re: How to import SWF to stage???
                      kglad Adobe Community Professional & MVP

                      copy the relevant code from your fla or class file(s).  paste that code into a message in this thread.

                      • 8. Re: How to import SWF to stage???
                        [no name] :D 2011 Level 1

                        The following is coded to a button in frame 1

                         

                        movieClip_4.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);

                         

                        function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void

                        {

                        gotoAndPlay(13);

                        }

                        The following is used to load the external swf animation (A1.swf)- published with stop( );
                        var my_loader:Loader = new Loader();
                        my_loader.load(new URLRequest("A1.swf"));
                        addChild(my_loader);
                        The swf loads when the button in frame one is clicked but as a image not animation

                        • 9. Re: How to import SWF to stage???
                          kglad Adobe Community Professional & MVP

                          use:

                           

                           

                          var my_loader:Loader = new Loader();
                          my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);
                          my_loader.load(new URLRequest("A1.swf"));
                          addChild(my_loader);

                          function f(e:Event):void{
                          // add only one of the two following listeners.  pick the correct one.
                          // if your button is in this (loading) swf:
                          movieClip_4.addEventListener(MouseEvent.CLICK, ff);
                          // if your button is in the loaded swf:
                          MovieClip(my_loader.content).movieClip_4.addEventListener(MouseEvent.CLICK, ff);
                          }


                          function ff(event:MouseEvent):void

                          {

                          MovieClip(my_loader.content).gotoAndPlay(13);

                          }


                           

                          • 10. Re: How to import SWF to stage???
                            [no name] :D 2011 Level 1

                             

                            I put the following code for frame 13 but an error shows up (line 2: access of undefined property f)
                            var my_loader:Loader = new Loader();
                            my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);
                            my_loader.load(new URLRequest("A1.swf"));
                            addChild(my_loader);
                            and for the other code
                            when you say loaded and loading..what do you mean?
                            when I tried to direct the code to my button it says
                            in as3, codes cannot be placed directly on objects. please select a frame or use the code snippets panel
                            • 11. Re: How to import SWF to stage???
                              kglad Adobe Community Professional & MVP

                              your code is in one of your two flas.  is the button in the same fla?

                              • 12. Re: How to import SWF to stage???
                                [no name] :D 2011 Level 1

                                I am only using one main fla

                                the other fla is my swf which i have already published.

                                 

                                The class loader worked fine and the swf loaded, is there any way i could make it not play immediately?? the stop(); to the external swf keeps it still ..I don't think it will move if I put in the main fla anyway. Correct me if I'm wrong, with any swf which has been stopped; if theres nothing to trigger the movement, it will keep still.

                                • 13. Re: How to import SWF to stage???
                                  kglad Adobe Community Professional & MVP

                                  use:

                                   

                                  var my_loader:Loader = new Loader();
                                  my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);
                                  my_loader.load(new URLRequest("A1.swf"));
                                  addChild(my_loader);

                                   

                                  function f(e:Event):void{
                                  movieClip_4.addEventListener(MouseEvent.CLICK, ff);
                                  }

                                   

                                  function ff(event:MouseEvent):void

                                  {

                                  MovieClip(my_loader.content).gotoAndPlay(13);

                                  }

                                  • 14. Re: How to import SWF to stage???
                                    [no name] :D 2011 Level 1

                                    I used the exact you provided me with but replaced MovieClip_4 with img1 (my button). When I click on the button the animation appears but overlapping the first frame and the following output

                                     

                                    TypeError: Error #1009: Cannot access a property or method of a null object reference.

                                    at theES_fla::MainTimeline/f()

                                     

                                    Can you please help me with this?

                                     

                                    Thanks

                                    • 15. Re: How to import SWF to stage???
                                      kglad Adobe Community Professional & MVP

                                      your img1 probably doesn't exist.

                                       

                                      copy and paste the code you're using.

                                      • 16. Re: How to import SWF to stage???
                                        [no name] :D 2011 Level 1

                                        i put the following in the actions for frame 1 (where the button img1 is placed)

                                         

                                        function f(e:Event):void{

                                        img1.addEventListener(MouseEvent.CLICK, ff);

                                        }

                                         

                                        function ff(event:MouseEvent):void

                                        {

                                        MovieClip(my_loader.content).gotoAndPlay(13);

                                        }

                                         

                                         

                                        and the following in the actions for frame 13

                                         

                                        var my_loader:Loader = new Loader();

                                        my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);

                                        my_loader.load(new URLRequest("A.swf"));

                                        addChild(my_loader);

                                         

                                        btw I changed the swf- removed the stop(); because it wouldn't play

                                         

                                        • 17. Re: How to import SWF to stage???
                                          kglad Adobe Community Professional & MVP

                                           

                                           

                                          put everything between the ///////////////////  in the actions for frame 1 (where the button img1 is placed)

                                           

                                          //////////////////////////////////////////

                                           

                                          function f(e:Event):void{

                                          img1.addEventListener(MouseEvent.CLICK, ff);

                                          }

                                           

                                          function ff(event:MouseEvent):void

                                          {

                                          MovieClip(my_loader.content).gotoAndPlay(13);

                                          }

                                           

                                           

                                          var my_loader:Loader = new Loader();

                                          my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);

                                          my_loader.load(new URLRequest("A.swf"));

                                          addChild(my_loader);

                                          /////////////////////////////////////////////

                                           

                                          // then put that stop() back in A.swf's first frame

                                          // make sure there's something on stage named img1 in frame 1 of the swf that contains the above code.

                                           

                                          • 18. Re: How to import SWF to stage???
                                            [no name] :D 2011 Level 1

                                            A: moving swf       A1: stopped swf

                                             

                                            The following is what I have put in for frame 1 like you told me and nothing in frame 13. This still gets the swf moving immediately. I also tried stopping the swf and adding it but all it did was immediately show the swf (stopped).

                                             

                                            stop();

                                             

                                            function f(e:Event):void{

                                            movieClip_4.addEventListener(MouseEvent.CLICK, ff);

                                            }

                                             

                                            function ff(event:MouseEvent):void

                                            {

                                            MovieClip(my_loader.content).gotoAndPlay(13);

                                            }

                                             

                                             

                                            var my_loader:Loader = new Loader();

                                            my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);

                                            my_loader.load(new URLRequest("A.swf"));

                                            addChild(my_loader);

                                            • 19. Re: How to import SWF to stage???
                                              kglad Adobe Community Professional & MVP

                                              again,

                                               

                                              // then put that stop() back in A.swf's first frame

                                               

                                              that first frame should be empty.

                                              • 20. Re: How to import SWF to stage???
                                                [no name] :D 2011 Level 1

                                                sorry i don't get you.

                                                 

                                                So the code I posted for frame 1, is that suppose 2 work??? or do I move to frame 13 and nothing in frame 1???

                                                 

                                                btw How does the swf move if it has been stopped?

                                                • 21. Re: How to import SWF to stage???
                                                  [no name] :D 2011 Level 1

                                                  //////////////////////////////////////////

                                                   

                                                  function f(e:Event):void{

                                                  img1.addEventListener(MouseEvent.CLICK, ff);

                                                  }

                                                   

                                                  function ff(event:MouseEvent):void

                                                  {

                                                  MovieClip(my_loader.content).gotoAndPlay(13);

                                                  }

                                                   

                                                   

                                                  var my_loader:Loader = new Loader();

                                                  my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);

                                                  my_loader.load(new URLRequest("A1.swf"));

                                                  addChild(my_loader);

                                                  /////////////////////////////////////////////

                                                   

                                                   

                                                  * you told me to put everything between /// in frame one right?

                                                  Correct me if I'm wrong; that would be loading the swf into frame one and there would be nothing in frame 13 to "gotoAndPlay(13)".

                                                  • 22. Re: How to import SWF to stage???
                                                    kglad Adobe Community Professional & MVP

                                                    you have 2 different swfs.  one that loads the other.  in frame 1 of the main swf that loads A1.swf put:

                                                     

                                                     

                                                     

                                                    //////////////////////////////////////////

                                                     

                                                    function f(e:Event):void{

                                                    img1.addEventListener(MouseEvent.CLICK, ff);

                                                    }

                                                     

                                                    function ff(event:MouseEvent):void

                                                    {

                                                    MovieClip(my_loader.content).gotoAndPlay(13); // assuming frame 13 is the first frame of A1.swf that you want to play

                                                    }

                                                     

                                                     

                                                    var my_loader:Loader = new Loader();

                                                    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);

                                                    my_loader.load(new URLRequest("A1.swf"));

                                                    addChild(my_loader);

                                                    /////////////////////////////////////////////

                                                     

                                                     

                                                    in frame 1 of A1.swf, put:

                                                     

                                                    stop();

                                                    • 23. Re: How to import SWF to stage???
                                                      [no name] :D 2011 Level 1

                                                      I just did exactly what you told me. Stopped the swf and put what you provided me with in frame 1 and nothing in frame 13. but the following errors occured

                                                       

                                                      Scene 1, Layer 'PAGES!', Frame 1, Line 1 1021: Duplicate function definition.

                                                      Scene 1, Layer 'PAGES!', Frame 1, Line 5 1021: Duplicate function definition.

                                                      Scene 1, Layer 'PAGES!', Frame 1, Line 11 1151: A conflict exists with definition my_loader in namespace internal.

                                                      • 24. Re: How to import SWF to stage???
                                                        kglad Adobe Community Professional & MVP

                                                        copy and paste the code you have in frame 1, layer PAGES!

                                                        • 25. Re: How to import SWF to stage???
                                                          [no name] :D 2011 Level 1

                                                          its the exact code you have provided me with between the /// ////

                                                          • 26. Re: How to import SWF to stage???
                                                            kglad Adobe Community Professional & MVP

                                                            then you added the suggested code to more than one layer.

                                                            • 27. Re: How to import SWF to stage???
                                                              [no name] :D 2011 Level 1

                                                              I deleted all actions and tried again. I put everything between // // in your post in frame 1 and nothing in frame 13.

                                                               

                                                              The stopped swf still appears immediately

                                                              • 28. Re: How to import SWF to stage???
                                                                kglad Adobe Community Professional & MVP

                                                                someone will need to download your files and do this for you.  i don't download and correct files unless i'm hired but someone else may do it gratis.

                                                                • 29. Re: How to import SWF to stage???
                                                                  [no name] :D 2011 Level 1

                                                                  aw. well my swf is a loading type of thing like you know when you are linked to another page, a loading icon appears for about 3-4 seconds before you are linked to the other page. Would that be easier to achieve?

                                                                  • 30. Re: How to import SWF to stage???
                                                                    kglad Adobe Community Professional & MVP

                                                                    no, that doesn't make anything easier.  it really doesn't get much easier than what you're trying to do.  i suspect you just don't understand enough about flash to follow the directions accurately.

                                                                    • 31. Re: How to import SWF to stage???
                                                                      [no name] :D 2011 Level 1

                                                                      you're right. I don't know too much about flash but can you please still try to assist me with this. Last time. Please post exactly what I should put in frame 1 and what I should put in frame 13. It would be ver much appreciated. Thanks

                                                                      • 32. Re: How to import SWF to stage???
                                                                        kglad Adobe Community Professional & MVP

                                                                        i've never suggested adding anything to frame 13.  i assume you want your main swf button to start your loaded swf at the loaded swf's frame 13.

                                                                         

                                                                        if that's true,

                                                                         

                                                                        in frame 1 of the main swf that loads A1.swf put and don't replay this frame:

                                                                         

                                                                         

                                                                         

                                                                        //////////////////////////////////////////

                                                                         

                                                                        function f(e:Event):void{

                                                                        img1.addEventListener(MouseEvent.CLICK, ff);

                                                                        }

                                                                         

                                                                        function ff(event:MouseEvent):void

                                                                        {

                                                                        MovieClip(my_loader.content).gotoAndPlay(13); // assuming frame 13 is the first frame of A1.swf that you want to play

                                                                        }

                                                                         

                                                                         

                                                                        var my_loader:Loader = new Loader();

                                                                        my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);

                                                                        my_loader.load(new URLRequest("A1.swf"));

                                                                        addChild(my_loader);

                                                                        /////////////////////////////////////////////

                                                                         

                                                                         

                                                                        in frame 1 of A1.swf, put:

                                                                         

                                                                        stop();

                                                                        • 33. Re: How to import SWF to stage???
                                                                          [no name] :D 2011 Level 1

                                                                          screenshot.jpg

                                                                          ^^This is how it appears. The stopped swf immediately shows up when exported. Would there be anything wrong with this? btw i changed the frame i want it to play in to 2 as shown above

                                                                          • 34. Re: How to import SWF to stage???
                                                                            kglad Adobe Community Professional & MVP

                                                                            do you have a stop() in frame 1 of A1.swf?  is frame 1 of A1.swf empty?

                                                                            • 35. Re: How to import SWF to stage???
                                                                              [no name] :D 2011 Level 1

                                                                              empty frame 1? ohh i get what you mean now.

                                                                               

                                                                              I tried that. swf is stopped and frame 1 is empty>> when I clicked on the button in frame 1, nothing changes because frame one is empty right? so how would I get it to play?

                                                                              • 36. Re: How to import SWF to stage???
                                                                                kglad Adobe Community Professional & MVP

                                                                                did you click img1 in your main swf?

                                                                                • 37. Re: How to import SWF to stage???
                                                                                  [no name] :D 2011 Level 1

                                                                                  yes but it stays on the same frame and no swf plays. Would that be because I stopped it? and its not showing up because the first frame is blank?

                                                                                  • 38. Re: How to import SWF to stage???
                                                                                    kglad Adobe Community Professional & MVP

                                                                                    use the following, click your img1 button once, then copy and paste the trace output (if there is any) here:

                                                                                     


                                                                                    in frame 1 of the main swf that loads A1.swf put and don't replay this frame:

                                                                                     

                                                                                     

                                                                                     

                                                                                    //////////////////////////////////////////

                                                                                     

                                                                                    function f(e:Event):void{

                                                                                    img1.visible=true;

                                                                                    img1.addEventListener(MouseEvent.CLICK, ff);

                                                                                    }

                                                                                     

                                                                                    function ff(event:MouseEvent):void

                                                                                    {

                                                                                    trace(event);

                                                                                    MovieClip(my_loader.content).gotoAndPlay(2);

                                                                                    }

                                                                                     

                                                                                    img1.visible=false;

                                                                                    var my_loader:Loader = new Loader();

                                                                                    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,f);

                                                                                    my_loader.load(new URLRequest("A1.swf"));

                                                                                    addChild(my_loader);

                                                                                    /////////////////////////////////////////////

                                                                                     

                                                                                     

                                                                                    in frame 1 of A1.swf, put:

                                                                                     

                                                                                    stop();

                                                                                    trace(1);

                                                                                     

                                                                                     

                                                                                    in frame 2 of A1.swf, put

                                                                                     

                                                                                    trace(2);

                                                                                    • 39. Re: How to import SWF to stage???
                                                                                      [no name] :D 2011 Level 1

                                                                                      The output is:

                                                                                       

                                                                                      1

                                                                                      1

                                                                                      1 2 Previous Next