Created
April 16, 2018 14:58
-
-
Save MadNoMad0/106a347b3551acf0b802104e27f839ac to your computer and use it in GitHub Desktop.
Minimalistic code to help visualize how the AIR runtime may freeze when queueing touch events.
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
package | |
{ | |
import flash.display.Shape; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
[SWF(width="1280", height="800", frameRate="60", backgroundColor="#F6F6F6")] | |
public class TouchFreeze extends Sprite | |
{ | |
private var circle:Shape; | |
private var direction:Number = 1.0; | |
public function TouchFreeze() | |
{ | |
circle = new Shape(); | |
circle.graphics.beginFill(0x003399); | |
circle.graphics.drawCircle(0, 0, 100); | |
circle.graphics.endFill(); | |
circle.x = circle.width / 2; | |
circle.y = 200.0; | |
addChild(circle); | |
addEventListener(Event.ENTER_FRAME, animateCircle); | |
} | |
private function animateCircle(event:Event):void | |
{ | |
if (circle.x <= circle.width / 2) | |
direction = 1.0; | |
else if (circle.x >= this.stage.stageWidth - circle.width / 2) | |
direction = -1.0; | |
circle.x += direction * 1.0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment