Need help with "if statement"

im trying to add controls to a simple movie clip. i want a button when clicked once to make an object (instance name “hand”) to slide forward, and when the button is clicked again i want the object to slide back into the orig. position. i know i have to use if statements to do this but i dont know how to do the script (i know it has to be written for the button and not the clip also). anyone know how to do this simple stuff?

Hi,

You could try something along the lines of

[AS]
if(_root.in) {
//move your object out
_root.in = false;
} else {
//move your object in
_root.in = true;
}
[/AS]

on your button. You would need to set the _root.in variable to true when your movie first started as booleans default to false.

HTH
Liz

Actually there was a thread about a similar kind of thing (by me) like 2 days ago, i think i called it ‘if function’ or something - you can always use the forum search feature to find it. in fact, http://www.kirupaforum.com/forums/showthread.php?s=&threadid=46583 lunatic provides a helpful link to a .fla by senocular which does exactly what you are looking for, but with three buttons :wink:

Well, that link to Sen’s fla is really geared more towards those who want to make sure that one animation finishes it’s thing before the next animation starts. This is useful for those folks out there who are button happy itchy clicker types. :stuck_out_tongue:

I suggest you skip that for now and just concentrate on getting your buttons and animation to work first.

Do a search for “previous frame” or something similar as I’ve seen lots of discussion about this same thing here on the forums. You can have just one motion tween that slides your object in one direction and then you can call for a reverse of that tween to make it move back. This is simpler and less processor intensive than having two tweens (I think; if not it’s still cool!).

Hey Insomniac - I’m sorry I dropped the ball on your own thread. It just got too complicated for me. Did you ever get it worked out? :h: Cheers mate :beer:

something like this?

Sweet! :thumb:

yeh lunatic it worked out, but im sure the code is not nearly as neat as it should be :stuck_out_tongue: thanks for the help though, im considering just not bothering with it and allowing the user to close the button themselves (its a draggable window thing)… :slight_smile:

those scripts and stuff you guys showed though are cool but they are super complex for just that simple action. my movie clip is set up like this. there is a stop action on frame 1, then motion bewteen frames 2 and 10 for the slide in motion. then theres a stop on 10 and motion between frames 11 and 20 for the slide out motion. all i need to know is what to type in for the IF script on my button to control the action. i know its something like:
if(currentframe._object) == 1 then goto and play 2 and then another script that says if(currentframe._object) == 10 then goto and play 11. i know its something like that but do i have to use a telltarget command or something. i know its pretty simple but im not sure exactly what the script order is. anyone know???