Skip to content

Commit 5b0bd20

Browse files
avm2: Use accessors instead of fields for TouchEvent properties
1 parent 67f80a0 commit 5b0bd20

File tree

1 file changed

+99
-16
lines changed

1 file changed

+99
-16
lines changed

core/src/avm2/globals/flash/events/TouchEvent.as

Lines changed: 99 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import flash.utils.ByteArray;
88
import flash.display.InteractiveObject;
99
import __ruffle__.stub_method;
1010

11+
[API("667")]
1112
public class TouchEvent extends Event {
1213
public static const PROXIMITY_BEGIN: String = "proximityBegin"; // [static] Defines the value of the type property of a PROXIMITY_BEGIN touch event object.
1314
public static const PROXIMITY_END: String = "proximityEnd"; // [static] Defines the value of the type property of a PROXIMITY_END touch event object.
@@ -25,18 +26,18 @@ public class TouchEvent extends Event {
2526
public static const TOUCH_ROLL_OVER: String = "touchRollOver"; // [static] Defines the value of the type property of a TOUCH_ROLL_OVER touch event object.
2627
public static const TOUCH_TAP: String = "touchTap"; // [static] Defines the value of the type property of a TOUCH_TAP touch event object.
2728

28-
public var touchPointID: int; // A unique identification number (as an int) assigned to the touch point.
29-
public var isPrimaryTouchPoint: Boolean; // Indicates whether the first point of contact is mapped to mouse events.
30-
public var localX: Number; // The horizontal coordinate at which the event occurred relative to the containing sprite.
31-
public var localY: Number; // The vertical coordinate at which the event occurred relative to the containing sprite.
32-
public var sizeX: Number; // Width of the contact area.
33-
public var sizeY: Number; // Height of the contact area.
34-
public var pressure: Number; // A value between 0.0 and 1.0 indicating force of the contact with the device.
35-
public var relatedObject: InteractiveObject; // A reference to a display list object that is related to the event.
36-
public var ctrlKey: Boolean; // On Windows or Linux, indicates whether the Ctrl key is active (true) or inactive (false).
37-
public var altKey: Boolean; // Indicates whether the Alt key is active (true) or inactive (false).
38-
public var shiftKey: Boolean; // Indicates whether the Shift key is active (true) or inactive (false).
39-
public var isRelatedObjectInaccessible: Boolean; // If true, the relatedObject property is set to null for reasons related to security sandboxes.
29+
private var _touchPointID: int; // A unique identification number (as an int) assigned to the touch point.
30+
private var _isPrimaryTouchPoint: Boolean; // Indicates whether the first point of contact is mapped to mouse events.
31+
private var _localX: Number; // The horizontal coordinate at which the event occurred relative to the containing sprite.
32+
private var _localY: Number; // The vertical coordinate at which the event occurred relative to the containing sprite.
33+
private var _sizeX: Number; // Width of the contact area.
34+
private var _sizeY: Number; // Height of the contact area.
35+
private var _pressure: Number; // A value between 0.0 and 1.0 indicating force of the contact with the device.
36+
private var _relatedObject: InteractiveObject; // A reference to a display list object that is related to the event.
37+
private var _ctrlKey: Boolean; // On Windows or Linux, indicates whether the Ctrl key is active (true) or inactive (false).
38+
private var _altKey: Boolean; // Indicates whether the Alt key is active (true) or inactive (false).
39+
private var _shiftKey: Boolean; // Indicates whether the Shift key is active (true) or inactive (false).
40+
private var _isRelatedObjectInaccessible: Boolean; // If true, the relatedObject property is set to null for reasons related to security sandboxes.
4041
private var _stageX: Number; // [read-only] The horizontal coordinate at which the event occurred in global Stage coordinates.
4142
private var _stageY: Number; // [read-only] The vertical coordinate at which the event occurred in global Stage coordinates.
4243

@@ -59,7 +60,6 @@ public class TouchEvent extends Event {
5960
this.shiftKey = shiftKey;
6061
}
6162

62-
6363
// [override] Creates a copy of the TouchEvent object and sets the value of each property to match that of the original.
6464
override public function clone(): Event {
6565
return new TouchEvent(this.type, this.bubbles, this.cancelable, this.touchPointID, this.isPrimaryTouchPoint,
@@ -84,17 +84,100 @@ public class TouchEvent extends Event {
8484
// [override] Returns a string that contains all the properties of the TouchEvent object.
8585
override public function toString(): String {
8686
return this.formatToString("TouchEvent", "type", "bubbles", "cancelable", "eventPhase", "touchPointID",
87-
"isPrimaryTouchPoint", "localX", "localY", "sizeX", "sizeY", "pressure", "relatedObject", "ctrlKey",
88-
"altKey", "shiftKey", "isRelatedObjectInaccessible", "stageX", "stageY");
87+
"isPrimaryTouchPoint", "localX", "localY", "stageX", "stageY", "sizeX", "sizeY", "pressure", "relatedObject",
88+
"ctrlKey", "altKey", "shiftKey");
8989
}
9090

9191
// Instructs Flash Player or Adobe AIR to render after processing of this event completes, if the display list has been modified.
9292
public native function updateAfterEvent(): void;
9393

94+
public function get touchPointID():int {
95+
return this._touchPointID;
96+
}
97+
public function set touchPointID(value:int):void {
98+
this._touchPointID = value;
99+
}
100+
101+
public function get isPrimaryTouchPoint():Boolean {
102+
return this._isPrimaryTouchPoint;
103+
}
104+
public function set isPrimaryTouchPoint(value:Boolean):void {
105+
this._isPrimaryTouchPoint = value;
106+
}
107+
108+
public function get localX():Number {
109+
return this._localX;
110+
}
111+
public function set localX(value:Number):void {
112+
this._localX = value;
113+
}
114+
115+
public function get localY():Number {
116+
return this._localY;
117+
}
118+
public function set localY(value:Number):void {
119+
this._localY = value;
120+
}
121+
122+
public function get sizeX():Number {
123+
return this._sizeX;
124+
}
125+
public function set sizeX(value:Number):void {
126+
this._sizeX = value;
127+
}
128+
129+
public function get sizeY():Number {
130+
return this._sizeY;
131+
}
132+
public function set sizeY(value:Number):void {
133+
this._sizeY = value;
134+
}
135+
136+
public function get pressure():Number {
137+
return this._pressure;
138+
}
139+
public function set pressure(value:Number):void {
140+
this._pressure = value;
141+
}
142+
143+
public function get relatedObject():InteractiveObject {
144+
return this._relatedObject;
145+
}
146+
public function set relatedObject(value:InteractiveObject):void {
147+
this._relatedObject = value;
148+
}
149+
150+
public function get ctrlKey():Boolean {
151+
return this._ctrlKey;
152+
}
153+
public function set ctrlKey(value:Boolean):void {
154+
this._ctrlKey = value;
155+
}
156+
157+
public function get altKey():Boolean {
158+
return this._altKey;
159+
}
160+
public function set altKey(value:Boolean):void {
161+
this._altKey = value;
162+
}
163+
164+
public function get shiftKey():Boolean {
165+
return this._shiftKey;
166+
}
167+
public function set shiftKey(value:Boolean):void {
168+
this._shiftKey = value;
169+
}
170+
171+
public function get isRelatedObjectInaccessible():Boolean {
172+
return this._isRelatedObjectInaccessible;
173+
}
174+
public function set isRelatedObjectInaccessible(value:Boolean):void {
175+
this._isRelatedObjectInaccessible = value;
176+
}
177+
94178
public function get stageX(): Number {
95179
return this._stageX;
96180
}
97-
98181
public function get stageY(): Number {
99182
return this._stageY;
100183
}

0 commit comments

Comments
 (0)