Skip to content

Instantly share code, notes, and snippets.

@destroytoday
Created January 3, 2011 06:51
Show Gist options
  • Save destroytoday/763190 to your computer and use it in GitHub Desktop.
Save destroytoday/763190 to your computer and use it in GitHub Desktop.
protected var shape:Shape = new Shape();
public function invalidate():void
{
shape.addEventListener(Event.ENTERFRAME, invalidateHandler);
}
protected function invalidateHandler(event:Event):void
{
stage.removeEventListener(Event.ENTERFRAME, invalidateHandler);
validate();
}
public function invalidate():void
{
stage.addEventListener(Event.RENDER, invalidateHandler);
stage.addEventListener(Event.ENTERFRAME, invalidateHandler);
stage.invalidate();
}
protected function invalidateHandler(event:Event):void
{
stage.removeEventListener(Event.RENDER, invalidateHandler);
stage.removeEventListener(Event.ENTERFRAME, invalidateHandler);
validate();
}
protected var timer:Timer = new Timer(0.0, 1);
public function TimerInvalidation()
{
timer.addEventListener(TimerEvent.TIMER_COMPLETE, invalidateHandler);
}
public function invalidate():void
{
timer.reset();
timer.start();
}
protected function invalidateHandler(event:TimerEvent):void
{
validate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment