Wednesday 6 February 2008

onEnterFrame in AS3

the old 'onEnterFrame' syntax has been removed in AS3 It seems everything has to be handled by the eventListener. Here's a simple


import flash.events.Event;
addEventListener(Event.ENTER_FRAME, dosmthng);
//
private function dosmthng(Event){
trace("smthng"+Event)//output:smthng[Event type="enterFrame" bubbles=false ...
}

and to remove it? Well, it’s a listener so you have to remove the Event Listener with :

removeEventListener(Event.ENTER_FRAME,funcToCall)

Besides ENTER_FRAME we have other Public Constants to use:

  • ACTIVATE
  • ADDED
  • ADDED_TO_STAGE
  • CANCEL
  • CHANGE
  • CLOSE
  • COMPLETE
  • CONNECT
  • DEACTIVATE
  • ENTER_FRAME
  • FULLSCREEN
  • ID3
  • INIT
  • MOUSE_LEAVE
  • OPEN
  • REMOVED
  • REMOVED_FROM_STAGE
  • RENDER
  • RESIZE
  • SCROLL
  • SELECT
  • SOUND_COMPLETE
  • TAB_CHILDREN_CHANGE
  • TAB_ENABLED_CHANGE
  • TAB_INDEX_CHANGE
  • UNLOAD

No comments: