Monthly Archive for February, 2009

Two event handler simplifications

In the past, I’ve always written very explicit formal event handlers and wired them up “properly”.  Lately I’ve been following a couple of shortcuts for the more simple event handlers and I’ve been enjoying the saved typing.  The first shortcut is using an anonymous function instead of a proper method.

myButton.addEventListener(MouseEvent.CLICK, function(event:Event) {mainStack.selectedIndex=1;} );

The second method is declaring the event handler right inside my mxml.

<mx:Button width=”256″ height=”256″ horizontalCenter=”-154″ top=”78″ >
<mx:click>
<![CDATA[
mainStack.selectedIndex=1;

]]>
</mx:click>
</mx:Button>