|
| 1 | +// compiled with mxmlc |
| 2 | + |
| 3 | +import flash.events.Event; |
| 4 | +import flash.display.DisplayObject; |
| 5 | + |
| 6 | +package { |
| 7 | + import flash.display.MovieClip; |
| 8 | + import flash.display.DisplayObject; |
| 9 | + import flash.events.Event; |
| 10 | + |
| 11 | + public class Test extends MovieClip { |
| 12 | + public function Test(){ |
| 13 | + var d = new MovieClip(); |
| 14 | + trace("// testing trivial getter") |
| 15 | + var e1 = new E1("e1", d); |
| 16 | + d.dispatchEvent(e1); |
| 17 | + |
| 18 | + trace("// testing 1-cycle-delayed getter") |
| 19 | + var e2 = new E2("e2", d); |
| 20 | + d.dispatchEvent(e2); |
| 21 | + } |
| 22 | + |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | + |
| 27 | +class E1 extends Event { |
| 28 | + private var dobj: DisplayObject; |
| 29 | + public function E1(type, dobj){ |
| 30 | + super(type, false, false); |
| 31 | + this.dobj = dobj; |
| 32 | + } |
| 33 | + override public function get target(): Object { |
| 34 | + trace("in get target()"); |
| 35 | + return this.dobj; |
| 36 | + } |
| 37 | + override public function clone(): Event { |
| 38 | + trace("in clone()"); |
| 39 | + return new E1(this.type, this.dobj); |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +class E2 extends Event { |
| 44 | + private var ready: Boolean; |
| 45 | + private var dobj: DisplayObject; |
| 46 | + public function E2(type, d){ |
| 47 | + super(type, false, false); |
| 48 | + this.ready = false; |
| 49 | + this.dobj = dobj; |
| 50 | + } |
| 51 | + override public function get target(): Object { |
| 52 | + trace("in get target()"); |
| 53 | + if (this.ready) { |
| 54 | + return this.dobj; |
| 55 | + } |
| 56 | + this.ready = true; |
| 57 | + return null; |
| 58 | + } |
| 59 | + override public function clone(): Event { |
| 60 | + trace("in clone()"); |
| 61 | + return new E2(this.type, this.dobj); |
| 62 | + } |
| 63 | +} |
0 commit comments