-
Notifications
You must be signed in to change notification settings - Fork 0
/
Owl.as
executable file
·58 lines (47 loc) · 1.14 KB
/
Owl.as
1
package { import flash.display.MovieClip; import flash.events.Event; public class Owl extends MovieClip { var eyes:String; public function Owl() { this.gotoAndStop(0); eyes = "closed"; } public function blink():void { } public function openEyes():void { eyes = "opening"; addEventListener(Event.ENTER_FRAME, playForward); } public function closeEyes():void { eyes = "closing"; addEventListener(Event.ENTER_FRAME, playReverse); } public function playForward(evt:Event):void { if (this.currentFrame == this.framesLoaded) { eyes = "open"; removeEventListener(Event.ENTER_FRAME, playForward); } else if ( eyes == "opening") { nextFrame(); } } public function sunUpdate():void { if (eyes == "opening" && this.currentFrame < this.framesLoaded) { nextFrame(); } else if (eyes == "closing" && this.currentFrame > 0) { prevFrame(); } } public function playReverse(evt:Event):void { if (this.currentFrame == 1) { eyes = "closed"; removeEventListener(Event.ENTER_FRAME, playReverse); } else if (eyes == "closing") { this.prevFrame(); } } }}