forked from: わかめちゃん
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tl3p
*/
// forked from say's わかめちゃん
// forked from ProjectNya's 教材:矩形(四角)を描こう!
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.filters.DropShadowFilter;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main extends Sprite {
private var shape:Shape;
private var eyes:Shape;
private var eyeL:Shape;
private var eyeR:Shape;
private static var color:uint = 0xff0000;
private var positions:Array;
public function Main() {
init();
}
private function init():void {
shape = new Shape();
addChild(shape);
shape.x = 232;
shape.y = 182;
shape.graphics.beginFill(color);
shape.graphics.drawCircle(0, 100, 160);
shape.graphics.drawCircle(0, 0, 200);
shape.graphics.endFill();
shape.filters = [new DropShadowFilter(10, 90, 0xff0066, 0.5, 16, 16, 1, 1, false, true, false)];
eyes = new Shape();
addChild(eyes);
eyes.x = 232;
eyes.y = 270;
eyes.graphics.beginFill(0x000000);
eyes.graphics.drawCircle(-70, 0, 30);
eyes.graphics.drawCircle(70, 0, 30);
eyes.graphics.endFill();
eyeL = new Shape();
addChild(eyeL);
eyeL.x = 162;
eyeL.y = 270;
eyeR = new Shape();
addChild(eyeR);
eyeR.x = 302;
eyeR.y = 270;
eyeL.graphics.beginFill(0xFFFFFF);
eyeL.graphics.drawCircle(0, 0, 10);
eyeL.graphics.endFill();
eyeR.graphics.beginFill(0xFFFFFF);
eyeR.graphics.drawCircle(0, 0, 10);
eyeR.graphics.endFill();
positions = new Array();
for (var n:uint = 0; n < 10; n++) {
positions.push({x: 0, y: 0});
}
addEventListener(Event.ENTER_FRAME, update, false, 0, true);
}
private function update(evt:Event):void {
positions.push({x: parent.mouseX - 232, y: parent.mouseY - 232});
var position:Object = positions.shift();
var distance:Number = Math.sqrt(position.x*position.x + position.y*position.y);
eyeL.x = 162 + position.x*10/distance;
eyeR.x = 302 + position.x*10/distance;
eyeL.y = eyeR.y = 270 + position.y*5/distance;
}
}
}