actionscript 3 - Understanding dispatchEvent(evt.clone()) -


i kind of new action script , trying understand existing code. here have myrestserviceevent , myrestservice. there many methods defined in myrestservice class dispach many events implement dispatchevent(evt.clone()); cannot understand. know myrestserviceevent has implemented clone(), dispatchevent(evt.clone()); do? appreciate if explain me process.

below little snapsht of 2 classes.

the event class

        public function myrestserviceevent(type:string, request:myrestrequest, result:* = null, bubbles:boolean=false, cancelable:boolean=false)         {             super(type, bubbles, cancelable);              this.result = result;             this.request = request;         }          /**          * override clone support re-dispatching          */         override public function clone():event         {             return new myrestserviceevent(type, this.request, this.result, bubbles, cancelable);         }     } } 

the event dispatcher class

public class myrestservice extends eventdispatcher     {          // ton of methods here below example of 1 of functions           private function checkadminerrorhandler(evt:myrestserviceevent):void         {             dispatchevent(evt.clone());         } } 

the clone() method creates duplicate instance of event object. creating fresh instance of class , setting properties same values original instance. custom events may override method handle replication of reference types correctly.

cloning required when event redispatched, read-only properties (bubbles, cancelable, currenttarget, target) can set again new values.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -