-
stoping a movie clip on its current x position action script 3
I have a mc that I am moving along the x axis dynamically. When it reaches a certain point it resets to 0 x.
I would like to stop the movement of the mc (on it's current x position) on mouse over and restart on mouse out.
Thanks in advance for your help.
Here is my code so far:
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_5);
function fl_EnterFrameHandler_5(event:Event):void
{
this.myObject.x += -1;
if (this.myObject.x == -1)
{
this.myObject.x = 110;
}
}
-
Code:
var isOver:Boolean = false;
myObject.addEventListener(MouseEvent.MOUSE_OVER, doOver);
myObject.addEventListener(MouseEvent.MOUSE_OUT, doOut);
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_5);
function fl_EnterFrameHandler_5(event:Event):void {
if (isOver == false) {
this.myObject.x += -1;
if (this.myObject.x == -1) {
this.myObject.x = 110;
}
}
}
function doOver(event:Event):void {
isOver = true;
}
function doOut(event:Event):void {
isOver = false;
}
-
thanks so much!
Thank you so much this works perfectly!
If I may ask a question to how this works. I understand the boolean is either off or on. I understand and see if the condition is false my animation is working. What I don't see is how you tell the animation to stop at the current x position if the condition is true.
Again, thanks again for your help it is so appreciated.
Originally Posted by dawsonk
Code:
var isOver:Boolean = false;
myObject.addEventListener(MouseEvent.MOUSE_OVER, doOver);
myObject.addEventListener(MouseEvent.MOUSE_OUT, doOut);
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_5);
function fl_EnterFrameHandler_5(event:Event):void {
if (isOver == false) {
this.myObject.x += -1;
if (this.myObject.x == -1) {
this.myObject.x = 110;
}
}
}
function doOver(event:Event):void {
isOver = true;
}
function doOut(event:Event):void {
isOver = false;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|