PDA

View Full Version : Button mouseover/mouseoff


KiLLer
12-30-2005, 01:13 AM
Hello again

I just started using flash8 recently, so I think this part of the forums is the best place to ask since there are planty of new features in flash8 that are not present in older versions or are very different.

I wanted to make a button that would animate itself when the mouse is over it then animate again when you move the mouse away. Think of it like mouseover=fade-in mouseoff=fade-out, but it doesnt have to be fading, I wanted to use other animations.

thanks. If something needs clearing up, I can try to explain better.:)
(admins, if my post is in the wrong place.. sorry, feel free to move it)

J_Miller
12-30-2005, 02:46 AM
The easiest way to accomplish this is with the newest version of the MovieClip Tweening Prototypes. They have added a frameTo() option that allows you to play a movieclip to a certain frame on rollover of your button (or the actualy movieclip, which ever way you set it up), and then play the animation in reverse on rollout.

http://laco.wz.cz/tween/?page=download

Hope that helps!

KiLLer
12-30-2005, 03:47 PM
THe extensions are for MX2004, im using Flash 8 Pro. How can I know if they are compatible?

billingsgate
12-31-2005, 07:04 AM
I'm not sure why you have to use the Tween class or third party tweening extensions to accomplish the task. Scripted animation is not necessarily the first choice. We're not even sure what kind of animation he is trying to accomplish.

There are a million possible ways to animate the button. The most straightforward way to do what he wants is to create each button as a movie clip, create whatever animation he wants inside the movie clip, put a stop(); action in frame 1, then putting the simple Script on the timeline:

button_mc.onRollOver = function(){
this.gotoAndPlay(frame number);
};
button_mc.onRollOut = function(){
this.gotoAndPlay(another frame number);
};

J_Miller
12-31-2005, 04:57 PM
Yes, I would agree that not everything has to be scripted, or for that matter needs to be some form a 3rd party addon. But there is one visual problem with what your suggesting, and that is if a person rolls over the button and then rolls off before the animation is complete, the animation will jump to the last frame (a frame never achieved) and then animate out. This will create some form a visual bug in the animation. Now let me also say that in very simple animations you may never notice this, but in a more complex rollover animation this would be very noticable. Furthering on that, this is why I suggested the tweeing prototypes. This would allow the animation to play as far it it gets while rolled over, and if the user rolls off before it completes the animation will play in reverse from whatever frame it was on when the user rolled out. this creates a much smoother effect.

As for KiLLer's question, if you have the newest version installed, all you have to do is open your extention manager and check the box next to the tweening extention under Flash 8. When its installed, by default its activated under MX, but if you activate it for Flash 8 it will work like a charm

Hope that helps!

billingsgate
01-01-2006, 02:25 PM
Yes, I would agree that not everything has to be scripted, or for that matter needs to be some form a 3rd party addon. But there is one visual problem with what your suggesting, and that is if a person rolls over the button and then rolls off before the animation is complete, the animation will jump to the last frame (a frame never achieved) and then animate out. This will create some form a visual bug in the animation. Now let me also say that in very simple animations you may never notice this, but in a more complex rollover animation this would be very noticable. Furthering on that, this is why I suggested the tweeing prototypes. This would allow the animation to play as far it it gets while rolled over, and if the user rolls off before it completes the animation will play in reverse from whatever frame it was on when the user rolled out. this creates a much smoother effect.


Quite true. Hence my recent obsessive interest in learning more about Action Script! I have created my own scripts to control frame-based movie clip animation to make for smooth transitions, specifically for rollover/rollout events. When working with characters, there's no other way to do it. Probably in some cases it would be simpler and more elegantly accomplished with pure scripted animation, as you point out.

Now, if only Killer would let us know what type of animation he's trying to accomplish, others may be able to advise him whether a timeline based or a script based solution is the most appropriate!

KiLLer
02-07-2006, 10:53 AM
well im trying to make a simple onrollover and onrollout animations. in general really I dont have a specific thing in mind. How do I install/activate the extension that you mentioned?

thanks.

J_Miller
02-07-2006, 12:51 PM
Go to the link above, download the newest mxp file and run it. by default it will install on Flash MX. If you need it in Flash 8, go to your extention manager and enable it under Flash 8

KiLLer
02-07-2006, 08:37 PM
this is the code i used

bt01.onRollOver = function() {
delete this.onEnterFrame;
this.gotoAndPlay(this._currentframe+1);

};
bt01.onRollOut = function() {
trace(this._currentframe);
if (this._currentframe != 1) {
this.onEnterFrame = function() {
this.gotoAndStop(this._currentframe-1);
if (this._currentframe == 1) {
delete this.onEnterFrame;
}
};
}
};

I got this code from another post with a sample file. I forgot who the author was but thanks.

Now, this code is inserted into a frame, then a MC with an instance name of bt01 that has preset animation inside (one way only) is on the stage. When the mouse is over the MC with the instance name, it plays the animation of the MC, when the mouse rolls out, it plays the same animation in reverse. Now the only thing I cant get to work is the link. I cant get it to like to another frame within the SWF or outside (HTML). Can anyone help?

antibob
02-08-2006, 04:13 PM
thats a great link, J_Miller...

Here is the code I use for complex rollover buttons: http://www.kirupa.com/developer/mx2004/button_effect.htm

KiLLer
02-09-2006, 12:13 AM
Thanks for that link. One question, when you use this

this.____.onRelease = function() {
gotoAndPlay("frame label")
}

will it work? I really can test it right now because im still in the process of making the buttons images themselves. I just want to know if that is a valid script.

thanks alot for all the help.