Actionscript Easing Menu Question

Hello,

I know how to make a menu using tweening to ease open/close a menu, but I know there has to be a better way of doing this with actionscript.

What actionscript could I use to make a box rise to a certain Y value and decrease to a certain Y value on a button click?

Thanks for your help!!

have you tried searching for easing? i’ve made a sample fla available [URL=http://www.kirupaforum.com/forums/showthread.php?t=62491]here

BW2, I’ve searched for easing, rising, drop-down, pop up, you name it! :slight_smile: I took a look at your .fla and it was very interesting! What I was wondering is if you could make the same effect by not having the box move to a certain location… meaning that the box grows when you click a button and shrinks when you click the button again. Can I modify your code to do the same thing?

you can’t create the “same effect” because i have 4 mc’s that move around and resize. but you can resize the boxes still without moving them.

you’ll just have to setup if and elseif statements. so let’s say you setup a variable named power. this will tell us whether or not the button has been clicked on (=1) or off(=0).

so for the MC (with instance name mc) AS:[AS]onClipEvent(load){
power=0; // off position to start
speed=5; // speed of easing
endW=50; // starting width
endH=100; // starting height
}
onClipEvent(enterFrame){
w = endW-this._width;
this._width += w/speed;
h = endH-this._height;
this._height += h/speed;
}[/AS]

and for the button AS:[AS]on(release){
if(mc.power==0){ // if mc is “off”
mc.endW=200;
mc.endH=400;
mc.power=1; // if it is pressed again, it will turn it “on”
}
else if(mc.power==1){ // if mc is “on”
mc.endW=50;
mc.endH=100;
mc.power=0; // if it is pressed again, it will turn it “off”
}
}[/AS]

// edit: sorry, i was thinking this was another post so if some of what i said in the paragraph doesn’t seem to make sense don’t worry about it. in short, you can’t create the “same” effect. but you could just make the box grow to the size that would equal the distance of the additional button.

the AS here still shows you how to resize a box though

Have a look here too;)
http://www.kirupaforum.com/forums/showthread.php?t=65908

scotty(-:

BWH2, THANKS SO MUCH!! This was EXACTLY what I was looking for! I’ll post the .fla for others to learn. Thanks!

you’re welcome.

BWH2, maybe you can help me again… I’m trying to get some text to rise up in the menu as it’s rising (so that the menu and text rise at the same speed). Been working on this for a couple of hours, but I can’t seem to get the text to be in sync with the menu. I’ve tried putting the text as a movie with a mask/tween, but it just doesn’t work right. Now I’m thinking that somehow I can tie this in to the actionscript I already have on the buttons… what do you advise?

i would advise using _y instead of _height. that way, you can have the box and text be the same mc. then you could just move it up and down accordingly (rather than adjusting the height). it will give the same effect, but will add text to it.

to complete it, just mask the area you want showing on the main timeline. that way, when the mc moves down on the y axis, it will only show the part you want.

BWH2, THANKS AGAIN! This worked perfectly!! Again I’ll attach the updated .fla for others to learn!

no problem.

Well, I thought my questions were over, but I have one more. Why is it that when I put everything into a movie clip, that nothing works anymore? I was thinking about putting everything in a movie clip to save space on my opening frames of the website, but now I don’t think this is possible? Does it have something to do with the onclipevent? Or does putting it into a movie clip complicate the power mc? What am I doing wrong? I’ll attach the .fla!!

Nevermind… the h values were just off. If you want the menu in a movie clip, see the attachment!

how to make the menu open and close in a smooth and fast motion?