20 Replies Latest reply on Nov 12, 2009 5:05 PM by Ned Murphy

    Play button is a mystery

    HannaB Level 1

      Hi, I have a one-frame Flash movie (containing movie clip and a button). Button is supposed to start the movie clip and run it once. I've searched high and low what action script to attach to the button to get the movie to start playing but I'm really bad at understanding even the basics.

       

      Anyone who can point me in the right direction for the simplest possible solution for a "Play" button.

       

      Thanks!

       

      Hanna in Tahoe

        • 1. Re: Play button is a mystery
          Ned Murphy Adobe Community Professional & MVP

          What version of actionscript are your Flash Publish Settings set for?

          • 2. Re: Play button is a mystery
            HannaB Level 1

            I'm using 2, but I don't know why. I can use either one, I guess.

            • 3. Re: Play button is a mystery
              Ned Murphy Adobe Community Professional & MVP

              Give the button an instance (via the properties panel).  Let's say you call it "btn".  Do the same for the movieclip, let's say you call that "mc".  In that actions layer that you show in the image, add the following code...

               

              btn.onRelease = function(){

                   mc.play();

              }

              • 4. Re: Play button is a mystery
                HannaB Level 1

                Hi Ned,

                I tried what you suggested and the movie just plays by itself — not waiting for me to click the button for it to start. I'm attaching the .fla so you can see what I did.

                 

                Thanks so much for helping me with this.

                 

                Won't let me attach the .fla for some reason. Attaching png of screen instead.

                 

                I also tried adding a stop(); to the action layer but that didn't change anything.

                • 5. Re: Play button is a mystery
                  Ned Murphy Adobe Community Professional & MVP

                  Does the movie have a stop(); command in the first frame?  If you zip your fla file you can usually attach it... but if it's a CS4 file I can't open it anyways.

                  • 6. Re: Play button is a mystery
                    satyajitbehera Level 1

                    Do it this way -

                    - put the button in first frame

                    - put the movieclip in second frame

                    - put  stop()  in first frame actions

                    - add the actions

                    playbtn.onRelease = function(){

                         gotoAndPlay(2);

                    }

                    • 7. Re: Play button is a mystery
                      HannaB Level 1

                      Hi Ned and Satyajit,

                      there is no stop in the first frame of the movie (there is however a stop in the last frame since I want the movie to stop there).

                       

                      I tried doing what Satyajit suggests below and that didn't work either.

                       

                      I'm attaching a CS3 version of the file that's compressed. Let's see if it can attach this time.

                       

                      Thanks guys!

                      • 8. Re: Play button is a mystery
                        brooksrv Level 2

                        I use this frequently in my development.  The top layer is an actions layer with a stop(); The second layer is for the button (btn_01). Both are in frame one. On the third layer, I have the movie clip (mc_01). The MC has an actions layer with a stop in frame 1 with a label name "stop". Frame two has been given the layer name "step 1"

                         

                        btn_01.onPress = function()

                        {
                          mc_01.gotoAndPlay("step 1");
                        }

                         

                         

                        I have also used the code below while placing everything in the same frame.

                         

                         

                        mc_01._visible = false;



                        btn_01.onRollOver = function()
                        {
                        mc_01._visible = true;
                        }

                        btn_01.onRollOut = function()
                        {
                        mc_01._visible = false;
                        }

                        • 9. Re: Play button is a mystery
                          Ned Murphy Adobe Community Professional & MVP

                          If you don't want your movieclip to play until you click the button, then you need to have a stop() in the first frame.  THis is for your original design, not what anyone else has suggested.

                          • 10. Re: Play button is a mystery
                            HannaB Level 1

                            Gentlemen, I just can't get it to work. I've tried every suggestion above and it just won't work. Did either of you look at the previously attached .zip file which contains my .fla? If you wouldn't mind, I'm sure it would take you 2 seconds to see what it is I'm just not getting.

                             

                            So thankful for you looking at this and trying to help. I have a pile of small animations I need to do once I've got this figured out.

                             

                            Thank you!

                            Hanna

                            • 11. Re: Play button is a mystery
                              Ned Murphy Adobe Community Professional & MVP

                              I couldn't open the file so I assume it is a CS4 file.

                              • 12. Re: Play button is a mystery
                                HannaB Level 1

                                I saved it down to CS3 so you should be able to. Wonder why that didn't work.

                                 

                                Here's what I have though right now:

                                 

                                Layers:

                                - Action layer, 1 frame with action script:

                                 

                                playBtn.onPress = function()

                                {

                                  movie.gotoAndPlay("step 1");

                                }

                                 

                                - Button layer with a button named "playBtn" – 1 frame

                                 

                                - Movie layer (layer name is "step1") with a movie clip named "movie" – 1 frame on timeline (60 frames in clip, "stop" on last frame)

                                 

                                 

                                Any ideas where I'm going wrong?

                                 

                                The button works fine as far as the rollover but it doesn't do anything when clicked. I also tried the following AS that you suggested:

                                 

                                playBtn.onRelease = function(){

                                     movie.play();

                                }

                                 

                                and I tried both with and without a "stop" in the first frame of the movie. Either, the movie starts and plays right away or it wont play at all. Just can't get the button to start it.

                                 

                                I also tried:

                                 

                                - put the button in first frame

                                - put the movieclip in second frame

                                - put  stop()  in first frame actions

                                - add the actions

                                playbtn.onRelease = function(){

                                     gotoAndPlay(2);

                                }

                                 

                                which also didn't work.

                                 

                                WHAT am I doing wrong (except trying to do something with Flash at all...)

                                 

                                THANKS!!!!!

                                 

                                Hanna

                                • 13. Re: Play button is a mystery
                                  Ned Murphy Adobe Community Professional & MVP

                                  Are you using "stop" or "stop();"  ?  The latter is the correct code.

                                   

                                  I will try again to open your file... it has to do with the way you named it and something weird this site does that makes me have to use special unzipping software.

                                  • 14. Re: Play button is a mystery
                                    HannaB Level 1

                                    stop();

                                    • 15. Re: Play button is a mystery
                                      HannaB Level 1

                                      I can email you the file if that helps.

                                      • 16. Re: Play button is a mystery
                                        Ned Murphy Adobe Community Professional & MVP

                                        I was able to get your file opened this time and it looks like you missed my very first direction... "Give the button an instance (via the properties panel)....etc..."  The most important part of that is the "via the properties panel".... it tends to be the most recurring error for new people, and sometimes for long time veterans as well.

                                         

                                        The name you assign to the object in the library is not the instance name, it is merely the name of the symbol in the library--the library name is simply for telling you what's what.  You need to select the item on the stage, go to the Properties panel, and enter the instance name in the little box that says Instance Name.

                                         

                                        Instance names are assigned to objects you place on the stage so that you can control them individually with code--allowing you to place several of the exact same button/movieclip symbols on the stage for different purposes.

                                         

                                        For the current state of your design, which you can revert to your original one frame design, you will also need to add a stop(); to frame 2.

                                        • 17. Re: Play button is a mystery
                                          Ned Murphy Adobe Community Professional & MVP

                                          If you'd like to see what I was telling you to do with your one frame design, here's your file updated to that:

                                           

                                          http://www.nedwebs.com/Flash/modulecs3.fla

                                          • 18. Re: Play button is a mystery
                                            HannaB Level 1

                                            Hi Ned, I know I'm blonde and all but I still can't get it to work after naming the button and movie in the property as well. Would you mind terribly to attach the .fla you corrected to this so I can get it back and then see what you did.

                                             

                                            The link you sent to see the .fla showed up as just code in my browser.

                                             

                                            Thanks Ned,

                                            Hanna

                                            • 19. Re: Play button is a mystery
                                              HannaB Level 1

                                              I figured it out!!!!! THanks!!!!

                                              • 20. Re: Play button is a mystery
                                                Ned Murphy Adobe Community Professional & MVP

                                                You're welcome