1 /** 2 * com.sekati.events.Event 3 * @version 1.1.5 4 * @author jason m horwitz | sekati.com 5 * Copyright (C) 2007 jason m horwitz, Sekat LLC. All Rights Reserved. 6 * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php 7 */ 8 9 import com.sekati.core.CoreObject; 10 import com.sekati.events.IEvent; 11 12 /** 13 * SASAPI Base Event class, works similarly to the AS3 Event class<br><br> 14 * 15 * The {@link com.sekati.events.Dispatcher} class excepts an object with at least one property: 'type:String' 16 * which is the identifier of the event. This is either the listener's function that is called when the event 17 * is dispatched, or the link through Delegate to the function to be called. Other optional properties 18 * are:'target:Object', which is the source of the event & 'data:Object', which may contain any information 19 * you wish to pass along with the event. 20 */ 21 class com.sekati.events.Event extends CoreObject implements IEvent { 22 23 private var _type:String; 24 private var _target:Object; 25 private var _data:Object; 26 private var _route:Array; 27 28 /** 29 * Constructor creates an event object fit for dispatching 30 * Note: the contents of the data parameter are copied to 31 * the Event object for legacy support. 32 * @param type (String) type of event 33 * @param target (Object) the object that dispatched this event. 34 * @param data (Object) optional data to pass with the event 35 * @return Void 36 */ 37 public function Event(type:String, target:Object, data:Object) { 38 _type = type; 39 _target = target; 40 _data = data; 41 // clone _data properties to the Event instance 42 for (var i in _data) this[i] = _data[i]; 43 _route = new Array( ); 44 } 45 46 public function get type():String { 47 return _type; 48 } 49 50 public function get target():Object { 51 return _target; 52 } 53 54 public function get data():Object { 55 return _data; 56 } 57 58 public function bubble(newTarget:Object):Void { 59 _route.push( _target ); 60 _target = newTarget; 61 } 62 }