Eye balls
click on the stage to create little eye balls, How can I add winking effect to them?
♥0 |
Line 54 |
Modified 2015-05-25 19:47:04 |
MIT License
archived:2017-03-10 08:37:57
ActionScript3 source code
/**
* Copyright O_MEG_A ( http://wonderfl.net/user/O_MEG_A )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/2vzQ
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class eye_ball extends Sprite{
private var eyeball:RotateToMouse;
public function eye_ball(){
stage.addEventListener(MouseEvent.CLICK, SpareEyeBall);
}
private function SpareEyeBall(event:MouseEvent):void{
eyeball = new RotateToMouse();
addChild(eyeball);
eyeball.x = event.stageX;
eyeball.y = event.stageY;
}
}
}
import flash.display.Sprite;
class EyeBall extends Sprite {
public function EyeBall() {
init();
}
public function init():void {
graphics.lineStyle(1, 0, 1);
graphics.beginFill(0xffffff);
graphics.drawCircle(0,0,20);
graphics.endFill();
graphics.beginFill(0x000000);
graphics.drawCircle(10,0,5);
graphics.endFill();
}
}
import flash.display.Sprite;
import flash.events.Event;
class RotateToMouse extends Sprite {
private var arrow:EyeBall;
public function RotateToMouse() {
init();
}
private function init():void {
arrow = new EyeBall();
addChild(arrow);
arrow.x = 0;
arrow.y = 0;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(event:Event):void {
var dx:Number = mouseX - arrow.x;
var dy:Number = mouseY - arrow.y;
var radians:Number = Math.atan2(dy, dx);
arrow.rotation = radians * 180 / Math.PI;
}
}