Skip to content

Instantly share code, notes, and snippets.

@Stray
Created January 19, 2011 13:11
Show Gist options
  • Save Stray/786147 to your computer and use it in GitHub Desktop.
Save Stray/786147 to your computer and use it in GitHub Desktop.
Toggle the position of a panel by decoupled handlers (for comparison with other approaches)
private var _nextMotion:Function = revealPanel;
private function togglePanelPosition(e:MouseEvent):void
{
_nextMotion();
}
private function revealPanel():void
{
moveTo(ON_STAGE_Y);
_nextMotion = hidePanel;
}
private function hidePanel():void
{
moveTo(OFF_STAGE_Y);
_nextMotion = revealPanel;
}
private function moveTo(yPos:Number):void
{
TweenLite.to(this, 1, {y:yPos});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment