Friday, 4 June 2010

Event Listeners

When adding eventListeners, it is normally necessary to write a specific function that will respond, because most of actionscript's pre-existing functions that you might think you could just use 'straight' as it were, get upset when they receive the event as a parameter.

e.g.

btn.addEventListener(MouseEvent.CLICK, stop);

stop() is not expecting any parameters, and doesn't like the event parameter it receives. I have found one exception to this rule, and the result is quite interesting.

btn.addEventListener(MouseEvent.CLICK, trace);

results in:

[MouseEvent type="click" bubbles=true cancelable=false eventPhase=3 localX=4.15 localY=-0.95 stageX=41.6 stageY=405.65 relatedObject=null ctrlKey=false altKey=false shiftKey=false buttonDown=false delta=0]

Interesting...I wonder what delta is, but can't be bothered to figure it out now.

No comments:

Post a Comment

Please enter your message here...