# Flash stop action in buttons



## Perseus (Feb 20, 2005)

OK, I am sort of creating a gallery, and using buttons so people can see my work. When they click on "1" the first piece will show up. I want it to stay there, until the user clicks on 2, 3, or whatever. For some reason, Flash is not allowing Stop actions on the down or hit state.  How would I go about executing what I want?


----------



## mweier (Mar 10, 2005)

frame actions don't work *in* buttons.  object actions can be assigned *on* buttons (by selecting button on stage).  this is where you'd put your button event handler.

simplest solution is to have a layer for art.  place a keyframe for each piece.  have another layer for buttons.  just one keyframe on that layer with duration as long as your art keys do.

then on each button, something like this: 

```
on (release){
     gotoAndStop(insertFramenumberhere);
}
```
obviously each button uses different number (or frame label, if you enclose in "s) for insertFramenumberhere so that it jumps to that piece of art.

finally, be sure you have a stop(); frame action on frame 1 of the timeline (i typically have an actions layer for that).  Otherwise your movie will loop through all art nonstop.

tons of more complex/tricky/elegant ways to do this, but this should get you started.


----------



## Natobasso (Mar 22, 2005)

Instead of each button being a "stop" action, why not have each button be a "go" action. Meaning each button takes you to a new frame/image. Though the previous post isn't wrong in the slightestjust wanted to bring up a different way of thinking.


----------



## mweier (Mar 23, 2005)

Natobasso: your different way of thinking is actually the same thing as what I said.  "gotoAndStop" is the actionScript command for having the playback head "go" to a frame.  However, since you don't want it to get to that image & then scrub through every other image in sequence (since they're hanging out on the subsequent frames), it's "gotoAndStop" so that it stops once it gets there.


----------



## Natobasso (Mar 23, 2005)

I do understand what you're trying to do.

Maybe if you thought of each picture frame as a separate "scene" in flash, then you wouldn't have to worry about it flowing and not stopping? You'd HAVE to click the forward or back button to make it move. Maybe not the most elegant solution 

Then each button's action would only be a "goto" action instead of a goto and stop action.

Otherwise, maybe you're producing a flash animation that has actions turned off; and that's why it's not working?


----------



## ElDiabloConCaca (Mar 23, 2005)

Unless a "stop" action is placed at the end of a scene, the movie will continue to play through, seamlessly, to the next scene.

Just make note of the last frame of your animation, then do what mwweier said with the snippet of code.

There are a number of different ways to accomplish this, depending on what you want to do.  Do you want transition effects, or will there be animation?  You can use a "gotoAndPlay" bit of code for these, with a "stop" action on the last frame of the animation.  If they're just static images on different frames, then you can scrap the "stop" action for the frames and just use a "gotoAndStop" bit of code.


----------

