How NOT to Code - Challenge 15

Feb 17, 2010

Today's challenge is in AS3 and for those working in Flex for a while this will be pretty easy. This code may actually be ok in very specific cases, but I still see people implementing this badly so I figure it was worth posting.

someObj.addEventListener(UserEvent.GET,getHandler);

Comments

lordb8r

lordb8r wrote on 02/17/105:13 PM

you have no way of checking to see if the event is valid for the component. My thought would be to use the metadata tag, and then inside of mxml for your component creation, you can then reference the tag:

<mx:Metadata>
[Event(name=UserEvent.Get)]
</mx:Metadata>

then in someObj:

< component:someObj UserEvent.Get="getHandler()" >
James

James wrote on 02/17/107:41 PM

, false, 0, true);

Write your comment



(it will not be displayed)