Skip to content

Instantly share code, notes, and snippets.

@MadNoMad0
Created April 16, 2018 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MadNoMad0/106a347b3551acf0b802104e27f839ac to your computer and use it in GitHub Desktop.
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.
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