5 Replies Latest reply on Jul 26, 2013 5:50 AM by Ned Murphy

    Play Button

    RenderDragon1

      I have a problem with my play button.

      Object(_root).button23.onRelease = function()

      {

                Object(_root).button23._parent.nextFrame();

                play();

      };

      I thought this would work but it ends up skipping a bunch of frames and pressing it again just repeats the last bunch of frames.

      Untitled.png

      Every a in the layer above the selected has the code that has been pasted to the top. The button has 0% alpha on the frames I don't want it to appear.

      I don't know why it doesn't want to continue playing.

        • 1. Re: Play Button
          Ned Murphy Adobe Community Professional & MVP

          Where is that code relative to the main (_root) timeline?  Where is button23 relative to the main (_root) timeline?

           

          The following line doesn't seem right...

           

                Object(_root).button23._parent.nextFrame();

           

          The _parent of button23 would be what you are targeting as Object(_root)

           

          You should be able to write that as

           

                _root.nextFrame();

          • 2. Re: Play Button
            RenderDragon1 Level 1

            Main timeline? Not sure what you mean.

            • 3. Re: Play Button
              Ned Murphy Adobe Community Professional & MVP

              When you first open your fla file you are looking at the main timeline (assuming you have the timeline panel opened).  Is that the timeline you show in the image you posted above?  Is that the timeline that contains the code you posted above?

              • 4. Re: Play Button
                RenderDragon1 Level 1

                Yes, that is the main timeline in the image above.

                Here is the code on each frame where my button is visible.

                stop();

                Object(_root).button23.onRelease = function()

                {

                          _root.nextFrame();

                          play();

                };

                On the keyframes where this code is placed, I want the animation to be stopped. Unfortunately, pressing the button just takes it to the next frame and stops there instead of playing from there.

                 

                Basically, I have individual consecutive keyframes that write out a sentence. When the sentence is fully written, I want the animation to stop and then the button will appear. I want this button, when clicked, to go to the next frame and continue playing.

                • 5. Re: Play Button
                  Ned Murphy Adobe Community Professional & MVP

                  Your explanation of what you have and what you want leaves alot to wonder about as to what needs to play and what needs to stop.  Let me explain what is wrong with the code you show and maybe that will help you get a better ideas of what you need to try to do...

                   

                  If all that code is on the main timeline there is not reason to be using any _root references.  You should avoid using _root references unnecessarily.  If button23 is on that timeline you can target it directly....

                   

                  button23.onRelease = function(){

                           // see below

                  }

                   

                            _root.nextFrame();

                            play();

                   

                  Those two commands are both targeting the same (_root) timeline since they are both in the _root timeline.  Again, using "_root" is unnecessary since you are in it.  So the first line should not have the _root. portion. 

                   

                  You have to make up your mind which you really want.  Either the main timeline goes to the next frame and stops or it plays.

                   

                  You say you want the button to go to the next frame and continue playing when it gets clicked... buttons don't typically play though it could be a movieclip rather than a button.  In any case, if you want something to play then you need to target it and tell it to play, so if it really is the button as you just said, then you should use...

                   

                             button23.play();

                  1 person found this helpful