forked from ruffle-rs/ruffle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avm2: Fix indirect event dispatching
- Loading branch information
Showing
5 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
tests/tests/swfs/avm2/eventdispatcher_dispatchevent_indirect/Test.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// compiled with mxmlc | ||
|
||
import flash.display.MovieClip; | ||
import flash.events.Event; | ||
import flash.events.EventDispatcher; | ||
import flash.events.IEventDispatcher; | ||
|
||
package { | ||
import flash.display.MovieClip; | ||
import flash.events.Event; | ||
import flash.events.EventDispatcher; | ||
|
||
public class Test extends MovieClip { | ||
public function Test() { | ||
var mc = new MovieClip(); | ||
addChild(mc); | ||
var child = new MovieClip(); | ||
mc.addChild(child); | ||
|
||
child.addEventListener("asdf", function(e){ | ||
trace("in child " + e.eventPhase); | ||
}); | ||
mc.addEventListener("asdf", function(e){ | ||
trace("in mc " + e.eventPhase); | ||
}); | ||
addEventListener("asdf", function(e){ | ||
trace("in root " + e.eventPhase); | ||
}); | ||
|
||
child.dispatchEvent(new Event("asdf", true)); | ||
|
||
trace(); | ||
var dispatcher = new EventDispatcher(child); | ||
dispatcher.addEventListener("asdf", function(e){ | ||
trace("in child's dispatcher " + e.eventPhase); | ||
}); | ||
|
||
dispatcher.dispatchEvent(new Event("asdf", true)); | ||
|
||
} | ||
|
||
} | ||
} | ||
|
||
class MyObject implements IEventDispatcher { | ||
private var dispatcher:EventDispatcher; | ||
public function MyObject() { | ||
dispatcher = new EventDispatcher(this); | ||
} | ||
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void{ | ||
dispatcher.addEventListener(type, listener, useCapture, priority); | ||
} | ||
public function dispatchEvent(evt:Event):Boolean{ | ||
return dispatcher.dispatchEvent(evt); | ||
} | ||
public function hasEventListener(type:String):Boolean{ | ||
return dispatcher.hasEventListener(type); | ||
} | ||
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void{ | ||
dispatcher.removeEventListener(type, listener, useCapture); | ||
} | ||
public function willTrigger(type:String):Boolean { | ||
return dispatcher.willTrigger(type); | ||
} | ||
} | ||
|
||
var object = new MyObject(); | ||
object.dispatchEvent(new Event("asdf")); | ||
object.addEventListener("asdf", function(){ trace("in listener") }) | ||
object.dispatchEvent(new Event("asdf")); | ||
trace(); |
9 changes: 9 additions & 0 deletions
9
tests/tests/swfs/avm2/eventdispatcher_dispatchevent_indirect/output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
in listener | ||
|
||
in child 2 | ||
in mc 3 | ||
in root 3 | ||
|
||
in child's dispatcher 2 | ||
in mc 3 | ||
in root 3 |
Binary file added
BIN
+1.16 KB
tests/tests/swfs/avm2/eventdispatcher_dispatchevent_indirect/test.swf
Binary file not shown.