Copy link to clipboard
Copied
Hello i am currently working on my first artillery game. I am following this great tutorial http://www.emanueleferonato.com/2007/04/28/create-a-flash-artillery-game-step-1/. However i want to make my game in AS3 so i am trying to implement the code to AS3 which has been no problem so far. But i am stuck on this step:
cannonball_fired.onEnterFrame = function() {
this._x += this.dirx/50;
this._y += this.diry/50;
};
How would i do something like this in AS3 without declaring a new canonball class? I just want to keep all the code on my actions frame. Thanks in advance
1 Correct answer
It could be something like...
cannonball_fired.addEventListener(Event.ENTER_FRAME, moveCF);
function moveCF(evt:Event):void {
var cf:MovieClip = MovieClip(evt.currentTarget);
cf.x += cf.dirx/50;
cf.y += cf.diry/50;
}
Copy link to clipboard
Copied
It could be something like...
cannonball_fired.addEventListener(Event.ENTER_FRAME, moveCF);
function moveCF(evt:Event):void {
var cf:MovieClip = MovieClip(evt.currentTarget);
cf.x += cf.dirx/50;
cf.y += cf.diry/50;
}
Copy link to clipboard
Copied
Thank you that was excactly what i was looking for
Copy link to clipboard
Copied
You're welcome John

