I'm working on learning the basics of AS3 and have been working through a tutorial book. We just made a class that, when linked to movie clips (or conceivably any sprite) would enlarge them when rolling the mouse over them. To make sure I remembered all the principles, I tried to make a class that would make the sprite spin when moused over it, and stop when I rolled out, however I'm having trouble making the ENTER_FRAME listener play nicely. Any idea where I'm going wrong?
package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.events.Event;
public class Spinnah extends Sprite
{
private var _origRotation:Number;
public function Spinnah()
{
_origRotation = this.rotation;
this.addEventListener(MouseEvent.ROLL_OVER, eFrameOn);
this.addEventListener(MouseEvent.ROLL_OUT, stopSpin);
}
private function eFrameOn (Event:MouseEvent):void
{
stage.addEventListener(Event.ENTER_FRAME, spin);
}
private function spin (event:Event):void
{
this.rotation += 1;
}
private function stopSpin (event:Event):void
{
stage.removeEventListener(Event.ENTER_FRAME, spin);
this.rotation = _origRotation;
}
}
}