Copy link to clipboard
Copied
hi, first of let me say that I very new to action scripting and with some tutorial I was able to learn a few things. With that being said, I was charged to make an animation using only action scripting, no motion tween in flash all on one frame. The idea was to move an object along the four corners of the stage. But I have a problem, I figured out how to move the object towards the right and down, but I can't get it to move left and up. here's what I have....and yes I know it's a mess.
import flash.events.Event;
addEventListener(Event.ENTER_FRAME,ballgo)
function ballgo(e:Event):void{
pacmanMc.x += 10;
}
stage.addEventListener(Event.ENTER_FRAME,dontmove);
function dontmove(e:Event):void{
if(pacmanMc.x>500){
pacmanMc.x=500
}
if(pacmanMc.x>490){
pacmanMc.y+=10;
}
}
stage.addEventListener(Event.ENTER_FRAME,freeze);
function freeze(e:Event):void{
if(pacmanMc.y>335){
pacmanMc.y=335
}
}
If anyone could help me before Sunday night it will be greatly appreciated.
if pacmanMc has reg point at the upper left use:
...
import flash.events.Event;
var leg:int = 1;
addEventListener(Event.ENTER_FRAME, pacmanGo);
function pacmanGo(e:Event):void{if(leg==1){
pacmanMc.x+=10;
if(pacmanMc.x>=stage.stageWidth-pacmanMc.width){
leg=2;
pacmanMc.x=stage.stageWidth-pacmanMc.width;
}
} else if(leg==2){
pacmanMc.y+=10;
if(pacmanMc.y>=stage.stageHeight-pacmanMc.height){
pacmanMc.y=stage.stageHeight-pacmanMc.height;
leg=3;
}
} else if(leg==3){
pacmanMc.x-=10;
if(pacmanMc.x<=0){
pa
Copy link to clipboard
Copied
if pacmanMc has reg point at the upper left use:
import flash.events.Event;
var leg:int = 1;
addEventListener(Event.ENTER_FRAME, pacmanGo);
function pacmanGo(e:Event):void{if(leg==1){
pacmanMc.x+=10;
if(pacmanMc.x>=stage.stageWidth-pacmanMc.width){
leg=2;
pacmanMc.x=stage.stageWidth-pacmanMc.width;
}
} else if(leg==2){
pacmanMc.y+=10;
if(pacmanMc.y>=stage.stageHeight-pacmanMc.height){
pacmanMc.y=stage.stageHeight-pacmanMc.height;
leg=3;
}
} else if(leg==3){
pacmanMc.x-=10;
if(pacmanMc.x<=0){
pacmanMc.x=0;
leg=4;
}
} else if(leg==4){
pacmanMc.y-=10;
if(pacmanMc.y<=0){
pacmanMc.y=0;
removeEventListener(Event.ENTER_FRAME, pacmanGo);
}
}
}
Copy link to clipboard
Copied
Thank you very much. But the code I have moves pacmanMc from the upper left to the upper right and then lower right. The problem is moving him from the lower right to the lower left and then to the upper left.
Copy link to clipboard
Copied
use the code i suggested.
it's easy to understand and does exactly that.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Copy link to clipboard
Copied
thank you very much for helping
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now