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);
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()" >