In my vast 2 months experience with Flex, I found myself doing stupid things a lot of times.
One of them is creating a new Event subclass every time I need a custom property. So, I created AuthorizeEvent, ServiceEvent, FormEvent, etc.
I did this until I found DynamicEvent. DynamicEvent is a class derived from Event that accepts to create properties inside of it dynamically.
So, instead of do:
new AuthorizeEvent(AuthorizeEvent.AUTHORIZED, user)
I started to do:
var e:DynamicEvent = new DynamicEvent(AuthorizeEvent.AUTHORIZED);
e.user = user;
Sounds cool, but I still rely on AuthorizeEvent. Just for a naming convention?!
I know this is bad, but we already have a convention about naming events. So... ChangeXXX or UserXXX.
Since we have a convention, we could simply use the name as strings... so:
var e:DynamicEvent = new DynamicEvent("UserAuthorized");
e.user = user;
Now, we decided to create a custom class, basically to encapsulate things that we may need in the future. So, our final class became core.events.DynEvent.
Here is the base implementation:
package core.events
{
import mx.events.DynamicEvent;
public dynamic class DynEvent extends DynamicEvent
{
public function DynEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
}
}
}
I hope this helps everyone that is looking for something like that.