martedì, aprile 22, 2008

ActionScript 3.0 onEnterFrame

A nice explanation of how to accomplish the same functionality the old AS2 “onEnterFrame” event in ActionScript 3.

In ActionScript 3.0, the frame event model has been changed from the ActionScript 2.0 version quite a bit. In ActionScript 2.0, if you wanted to perform a task every time you entered a frame, you would type:

onEnterFrame = function(){
trace("Do Something");
}

In ActionScript 3.0, you must use an event listener format to perform a frame event. For example…

addEventListener(Event.ENTER_FRAME,myFunction);
function myFunction(event:Event) {
trace("Do Something");
}