Adobe flex - Event metaData Tag and clone method -


i have few questions related events.

can explain exact need of overriding clone() while creating custom events? read in flex cookbook need override clone() in case want redispatch event. mean when want event bubbled display hierarchy, dispatched event should our custom cloned event , not event object?

second, need of metadata tag:

[event(name="modelevent", type="com.abc.data.model.modelevent")]
public class loginmodel extends eventdispatcher {}

i understand need extend eventdispatcher in case want dispatch event class, in cases need use metadata tag?

my third question if write dynamic customeventclass extends event", can use dynamic keyword purpose?

1) redispatching event isn't same bubbling. have (third party) component dispatches event without bubbling. , want delegate event further. in case need redispatch event:

mybutton.addeventlistener(mouseevent.click, mybuttonclickhandler);  ...  private function mybuttonclickhandler(event:mouseevent):void {     dispatchevent(event); } 

in case line dispatchevent(event) produces new event cloning it.

if you're sure components custom events won't used others can omit implementing clone(). knows… best practices best practices follow them.

2) event metatag solves @ least 2 practical tasks:

  • it allows compiler validate usage of corresponding attribute in mxml when uses target component in mxml. compiler produce error without event metatag declaration far event attribute unknown.
  • it allows ide use code completion of available events when you're typing addeventlistener in actionscript.

3) keyword dynamic allows use fields instance if not declared in class without compiler warning (but without advantage of ide's code completion). in event class allows carry custom data it. event classes declares data field of object type purposes avoiding of usage of dynamic classes (like in dataevent).


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -