# Question about moving an mc with actionscript

**URL:** <https://forum.kirupa.com/t/question-about-moving-an-mc-with-actionscript/239293>\
**Category:** flash\
**Created:** [September 20, 2007, 8:46am UTC](https://forum.kirupa.com/t/question-about-moving-an-mc-with-actionscript/239293 "2007-09-20T08:46:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CoDe\_ReD](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/code_red/32/336_2.png) [@CoDe\_ReD](https://forum.kirupa.com/u/CoDe_ReD)\
**Post date:** [September 20, 2007, 8:46am UTC](https://forum.kirupa.com/t/question-about-moving-an-mc-with-actionscript/239293/1 "2007-09-20T08:46:48Z")

</div>

Hi ppl,

I’m currently working on a school project for a mobile phone. I’m using flash lite 2.0 and I’m trying to get a movieclip to move on a buttonpress.

I’m using the following code on the timeline:  
[AS]function left() {  
varPos = -240;  
if (app.\_x\<=120) {  
this.enabled = false;  
tweenMenu(mx.transitions.easing.Strong.easeInOut);  
}  
}  
function right() {  
varPos = 240;  
trace(app.\_x);  
if (app.\_x\>=120) {  
this.enabled = false;  
tweenMenu(mx.transitions.easing.Strong.easeInOut);  
}  
}  
function tweenMenu(easeType) {  
var begin = app.\_x;  
var end = app.\_x-varPos;  
var time = 15;  
var mc = app;  
new mx.transitions.Tween(mc, “\_x”, easeType, begin, end, time);  
}[/AS]

Also I have a button offstage that functions as a key-catcher with this code applied to it:

[AS]on (keyPress “\<Left\>”) {  
left();  
}  
on (keyPress “\<Right\>”) {  
right();  
}[/AS]

Now this is all working fine, but the problem is that when I spam button press the left or right key it starts the animation again and again. This causes the movieclip to end up on a diffrent location then I intend it to be. So what I need is that when the button is pressed once, the function will execute once, and it does not react to the buttons during the animation.

Thnx in advance,

CoDe-ReD.
