PDA

View Full Version : Getting a button to return to certain frame in Over state


Bevans
07-02-2006, 01:34 AM
First, the example: http://www.theinsaneasylum.com/bevansdesign/demo.html

I've got a button set up this way:

Up State: Plain blue dot. Does nothing.
Over State: Blue dot grows, fades away, showing image. Doesn't loop.
Down State: Image spins in place continuously.

Flash's default behavior is to go back to the Over State once you've released your mouse button, but I'd like to have it go to the last frame of the movie clip I have on the Over state instead, so it doesn't do the zooming out thing again. Is there any way to do that?

Thanks for your help!

EDIT: And now that I think about it, it would be nice if I could have another movie play when you Mouse-off it.

tfoston
07-02-2006, 08:16 AM
myButton_btn.onRelease = function(){
gotoAndPlay(what ever frame you need)
}

Bevans
07-02-2006, 05:31 PM
Cool, thanks. But where do I put it? I've tried putting it on the button and in the main timeline (new layer of course), but they didn't work. Or maybe I'm just doing something wrong.

diesel5599
07-03-2006, 04:51 PM
myButton_btn.onRelease = function(){
gotoAndPlay(what ever frame you need)
}


That will not work for the over state, the following code will:

myButton_btn.onRollOver = function () {
gotoAndPlay("DesiredFrame");
}

If the desired target frame is in the same MC as the button, then the code should go in the actions layer of the current MC. If the desired frame is somewhere else in the movie then you can still place the code in the actions layer of the current MC but you will need the _parent tag or if it is a nested MC it may be easier to use the _root designator. It sounds like you are having problems with hierachy, I suggest you brush up on hierarchy using Adobe's livedocs.

Below is an example of code placed in the actions layer within a MC that is targetting a frame in the root timeline which is one layer above the MC:

myButton_btn.onRollOver = function () {
this._parent.gotoAndPlay("DesiredFrame");
}

or you could write it like this:

myButton_btn.onRollOver = function () {
_root.gotoAndPlay("DesiredFrame");
}

Bevans
07-04-2006, 06:50 AM
Thanks for the help. I found another way to do it - I just made a transparent button on one layer, then directly under it in another layer, created a movie clip divided into sections with other movie clips, and used actionscript on the button to change frames in the movie clip.