PDA

View Full Version : Button Rollout Question


QuietStorm
08-22-2002, 08:04 PM
Hi, first time posting here, and I have a simple question. How do you create buttons that have a "reverse frame(?)" type of thing on the roll out. For example if I create a button that has a fading in effect on a rollover, when you roll out, how do you make the button fade out, instead of just going straight back to the regular state? If there's a tutorial or anything else on this it would be much appreciated. Thanks in advance.

Peace,
QS

Rupert
08-23-2002, 12:15 AM
Hi and welcome!

You can put little movieclips inside the states of your buttons and get some ok results - but I personally don't like that method. I think you are better to use a movieClip instead of a button that gives you more freedom.

One way is to crate a moveclip on the stage, give it a creative instance name like "movieClipNameHere" set its alpha to say 10. Then add the following code:

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
if (_root.movieClipNameHere._alpha<100) {
_root.movieClipNameHere._alpha = (_alpha+20);
}
} else if (_root.movieClipNameHere._alpha>10) {
_root.movieClipNameHere._alpha = (_alpha-5);
}
}

xxlm
08-23-2002, 12:40 AM
Some function:

Movieclip.prototype.fadein = function (speed) {
this.enabled = false;
this.onEnterFrame = function () {
this._alpha += speed;
if (this._alpha > 100) {
delete this.onEnterFrame;
this.enabled = true;
this._alpha = 100;
}
}
}

Movieclip.prototype.fadeout = function (speed) {
this.enabled = false;
this.onEnterFrame = function () {
this._alpha -= speed;
if (this._alpha < 0) {
delete this.onEnterFrame;
this.enabled = true;
this._alpha = 0;
}
}
}


Put this script on the first frame of your main timeline and then use like this:
MyMC.fadein(yourspeed);
MyMC.fadeout(yourspped);
So put this code in the rollOver or rollOut event.

In a few week I'll put my website online, with some functions I've made.... ;) (include this one).
(publicity héhéhé).

mcdanyel
08-23-2002, 01:27 AM
Hey Storm,Evie

A simple way to do if you do not like a lot of programming is to use an "invisible button" and a movieclip together.

Make a button with only a hit state in it, then make a movie clip with all the animations your heart could desire. Throw a frame label at the beginning of each animation in the movie clip.

Then just add the simple "onRollover" ect actions to your button instance and tell it to go an play the animation in the movieclip by calling teh framelabel. The system works great.

The other methods are great but I am not good at heavy scripting so I always follow the K.I.S.S. method since I suck at hard core actionscripting (K.I.S.S. >>> Keep It Simple Stupid).

mcdanyel
08-23-2002, 01:27 AM
Hey Storm,

A simple way to do if you do not like a lot of programming is to use an "invisible button" and a movieclip together.

Make a button with only a hit state in it, then make a movie clip with all the animations your heart could desire. Throw a frame label at the beginning of each animation in the movie clip.

Then just add the simple "onRollover" ect actions to your button instance and tell it to go an play the animation in the movieclip by calling teh framelabel. The system works great.

The other methods are great but I am not good at heavy scripting so I always follow the K.I.S.S. method since I suck at hard core actionscripting (K.I.S.S. >>> Keep It Simple Stupid).

mcdanyel
08-23-2002, 01:28 AM
Sorry fat fingers...hit the "submit button" twice.

QuietStorm
08-23-2002, 04:28 AM
Thanks for all the methods guys! I know this is kinda asking a lot, but I was wondering if any of you can attach an swf. file so I can follow everything clearer. I'm more of a visual/tutorial type of learner =) Thanks again.

QS

Rupert
08-23-2002, 06:26 AM
I tried to build you a sample of all three methods mentioned above but I couldn't get XXLMs code to work - I'm sure its obvious but I'm tired and probably just being daft - Please assist if you want!

otherwise here are a couple of ways.

xxlm
08-23-2002, 01:46 PM
Hey Ruppert, the code I gave only works for MX...
If you have it, try to do this:
Put the code in the frame 1 of the movie.
Then in a MC you've made put (ie).

onClipEvent(mouseUp) {
this.fadeout(2);
}


Then you'll see it disapear...
That's all!
;)

I've made some more "powerful" functions with setInterval. You'll see it in a week (I hope!) in my website (not online yet).

mcdanyel
08-23-2002, 02:56 PM
Hey Storm,

Let me know if you still need swf. I see that you already have some.

QuietStorm
08-24-2002, 01:23 AM
Thanks to everyone for the help! I was going over the methods in the .swf file and they both look great!

QS