ZFGC
Resources => Coding => Topic started by: OozyGorilla on November 12, 2008, 09:52:31 am
-
Not sure if this is the right forum. If not, please move.
Alright. I've been working on this project for a while for my flash class. I've already turned it in but I'm fixing it the way I wanted.
Anyway, my problem is I want a Movie Clip (instance name = menu_txt) to rotate and come to a smooth stop when I click a button (instance name = up_arrow). It works but only once.
(http://img.photobucket.com/albums/v198/DarkLink6235/Misc/help-1.jpg)
So, basically, I have that image. I want it to rotate counter-clockwise. It starts out where it says "Str." The rotation when I click the up arrow works from 1 to 2 but doesn't from 2-3 3-4.
The code I have set is on the frame on an other layer.
up_arrow.onRelease = function() {
if (menu_txt.rotation = 0){
trace(menu_txt.rotation);
menu_txt.rotateTo (-90, 2, "easeOut", 0);
swishSound.start(0, 1);
}else if (menu_txt.rotation = -90){
trace(menu_txt.rotation);
menu_txt.rotateTo (-180, 2, "easeOut", 0);
swishSound.start(0, 1);
}else if (menu_txt.rotation = -190){
trace(menu_txt.rotation);
menu_txt.rotateTo (-270, 2, "easeOut", 0);
swishSound.start(0, 1);
}else if (menu_txt.rotation = -270){
knockSound.start(0, 1);
}
}
Like I said, the first one works but the other 3 don't. Any ideas. I can provide more info if need be.
-
It could automatically be converting that -90 rotation to 270.
I'd probably use a variable to keep track of how many times it's been rotated for when you want it to stop, then just rotate it by it's current rotation - 90. You should be able to do something like "if (menu_txt.rotation%90==0)" to make sure it isn't between slots before you start rotating it.
-
I figured it out.
I need to change all the "if (menu_txt.rotation = 0)" to "if (menu_txt.rotation == 0)"
Funny how code works that way.
-
Ah, yeah, I make that mistake sometimes too. I usually get a warning from the compiler for it though.