-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add mouse_double_click_events test
- Loading branch information
1 parent
1c3128c
commit c62bd1c
Showing
5 changed files
with
337 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package { | ||
import flash.display.DisplayObject; | ||
import flash.display.MovieClip; | ||
import flash.display.Sprite; | ||
import flash.events.MouseEvent; | ||
import flash.geom.ColorTransform; | ||
|
||
[SWF(width="100", height="20")] | ||
public class Test extends Sprite { | ||
private var colorIndex: int = 0; | ||
private var colors: Array = [ | ||
0xFF0000, | ||
0x00FF00, | ||
0x0000FF, | ||
0x00FFFF, | ||
0xFF00FF, | ||
0xFFFF00 | ||
]; | ||
private var events: Array = [ | ||
MouseEvent.CLICK, | ||
MouseEvent.DOUBLE_CLICK, | ||
MouseEvent.MOUSE_UP, | ||
MouseEvent.MOUSE_DOWN | ||
]; | ||
|
||
public function Test() { | ||
var a = newMovieClip(0, 0, 20, 20, "A"); | ||
var b = newMovieClip(20, 0, 40, 20, "B"); | ||
b.addChild(newMovieClip(20, 0, 20, 20, "C")); | ||
var d = newMovieClip(60, 0, 20, 20, "D", false); | ||
addChild(a); | ||
addChild(b); | ||
addChild(d); | ||
for each (var eventName in [MouseEvent.MOUSE_UP, MouseEvent.RIGHT_MOUSE_UP, MouseEvent.MIDDLE_MOUSE_UP]) { | ||
registerListener(eventName, stage, "stage"); | ||
} | ||
} | ||
|
||
private function newMovieClip(x:Number, y:Number, w:Number, h:Number, name:String, registerDoubleClickEvent:Boolean = true):MovieClip { | ||
var sprite:Sprite = new Sprite(); | ||
sprite.graphics.beginFill(colors[colorIndex++]); | ||
sprite.graphics.drawRect(0, 0, w, h); | ||
sprite.tabEnabled = true; | ||
sprite.doubleClickEnabled = true; | ||
var movieClip:MovieClip = new MovieClip(); | ||
movieClip.addChild(sprite); | ||
movieClip.x = x; | ||
movieClip.y = y; | ||
movieClip.doubleClickEnabled = true; | ||
for each (var eventName in events) { | ||
if (!registerDoubleClickEvent && eventName == MouseEvent.DOUBLE_CLICK) { | ||
continue; | ||
} | ||
|
||
registerListener(eventName, sprite, name + ".sprite"); | ||
registerListener(eventName, movieClip, name); | ||
} | ||
return movieClip; | ||
} | ||
|
||
private function registerListener(eventName:String, object:DisplayObject, name:String) { | ||
object.addEventListener(eventName, function(evt:MouseEvent):void { | ||
var formatted:String = evt.formatToString( | ||
"MouseEvent","type","bubbles","cancelable", | ||
"eventPhase","relatedObject","ctrlKey","altKey","shiftKey","buttonDown","delta"); | ||
trace("Event " + eventName + " at " + name + ": " + formatted); | ||
|
||
if (eventName == MouseEvent.DOUBLE_CLICK) { | ||
object.transform.colorTransform = new ColorTransform(0.4, 0.4, 0.4); | ||
} | ||
if (eventName == MouseEvent.CLICK) { | ||
object.transform.colorTransform = new ColorTransform(0.8, 0.8, 0.8); | ||
} | ||
}); | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
tests/tests/swfs/avm2/mouse_double_click_events/input.json
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 @@ | ||
[ | ||
{ "type": "MouseMove", "pos": [10,10] }, | ||
{ "type": "MouseDown", "pos": [10,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [10,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [10,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [10,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [10,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [10,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [10,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [10,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [10,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [10,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [10,10], "btn": "Left", "index": 2 }, | ||
{ "type": "MouseUp", "pos": [10,10], "btn": "Left" }, | ||
|
||
{ "type": "MouseMove", "pos": [30,10] }, | ||
{ "type": "MouseDown", "pos": [30,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [30,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [30,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [30,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [30,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [30,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [30,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [30,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [30,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [30,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [30,10], "btn": "Left", "index": 2 }, | ||
{ "type": "MouseUp", "pos": [30,10], "btn": "Left" }, | ||
|
||
{ "type": "MouseMove", "pos": [50,10] }, | ||
{ "type": "MouseDown", "pos": [50,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [50,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [50,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [50,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [50,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [50,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [50,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [50,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [50,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [50,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [50,10], "btn": "Left", "index": 2 }, | ||
{ "type": "MouseUp", "pos": [50,10], "btn": "Left" }, | ||
|
||
{ "type": "MouseMove", "pos": [70,10] }, | ||
{ "type": "MouseDown", "pos": [70,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [70,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [70,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [70,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [70,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [70,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [70,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [70,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [70,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [70,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [70,10], "btn": "Left", "index": 2 }, | ||
{ "type": "MouseUp", "pos": [70,10], "btn": "Left" }, | ||
|
||
{ "type": "MouseMove", "pos": [90,10] }, | ||
{ "type": "MouseDown", "pos": [90,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [90,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [90,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [90,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [90,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [90,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [90,10], "btn": "Left" }, | ||
{ "type": "MouseUp", "pos": [90,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [90,10], "btn": "Left", "index": 1 }, | ||
{ "type": "MouseUp", "pos": [90,10], "btn": "Left" }, | ||
{ "type": "MouseDown", "pos": [90,10], "btn": "Left", "index": 2 }, | ||
{ "type": "MouseUp", "pos": [90,10], "btn": "Left" } | ||
] |
Oops, something went wrong.