# Need help with "if statement"

**URL:** <https://forum.kirupa.com/t/need-help-with-if-statement/42166>\
**Category:** Uncategorized\
**Created:** [February 5, 2004, 10:57pm UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166 "2004-02-05T22:57:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanc](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@seanc](https://forum.kirupa.com/u/seanc)\
**Post date:** [February 5, 2004, 10:57pm UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166/1 "2004-02-05T22:57:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 11:22pm UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166/2 "2004-02-05T23:22:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 11:31pm UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166/3 "2004-02-05T23:31:05Z")

</div>

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](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 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 11:35pm UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166/4 "2004-02-05T23:35:23Z")

</div>

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. 😛

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 🍺

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 11:35pm UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166/5 "2004-02-05T23:35:44Z")

</div>

something like this?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 11:46pm UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166/6 "2004-02-05T23:46:31Z")

</div>

Sweet! :thumb:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2004, 8:16am UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166/7 "2004-02-06T08:16:07Z")

</div>

yeh lunatic it worked out, but im sure the code is not nearly as neat as it should be 😛 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)… 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2004, 8:40pm UTC](https://forum.kirupa.com/t/need-help-with-if-statement/42166/8 "2004-02-06T20:40:49Z")

</div>

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???
