flash on 2014-11-3
♥0 |
Line 81 |
Modified 2014-11-04 00:23:57 |
MIT License
archived:2017-03-30 11:53:06
ActionScript3 source code
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/m98r
*/
package {
import flash.text.TextField;
import flash.geom.Point;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
deb = new TextField();
deb.mouseEnabled = false;
deb.width = 320;
deb.height = 240;
addChild(deb);
hip = new Sprite();
hip.graphics.clear();
hip.graphics.beginFill(0,0.5);
hip.graphics.drawEllipse(-16,-8,32,24);
hip.graphics.endFill();
hip.x=200;
hip.y=200;
addChild(hip);
body = new Sprite();
body.graphics.clear();
body.graphics.beginFill(0,0.5);
body.graphics.drawEllipse(-16,-32,32,64);
body.graphics.endFill();
body.x = 0;
body.y = -16;
hip.addChild(body);
arm = new Sprite();
arm.graphics.clear();
arm.graphics.beginFill(0,0.5);
arm.graphics.drawEllipse(-8,-8,64,16);
arm.graphics.endFill();
arm.y=-16-4;
arm.x=4;
body.addChild(arm);
neck = new Sprite();
neck.y=-32;
neck.x=-4;
neck.graphics.clear();
neck.graphics.beginFill(0,0.5);
neck.graphics.drawRect(-8,-4,16,10);
neck.graphics.endFill();
body.addChild(neck);
head = new Sprite();
head.graphics.clear();
head.graphics.beginFill(0,0.5);
head.graphics.drawRect(-16,-16,32,32);
head.graphics.endFill();
head.graphics.beginFill(0,0.5);
head.graphics.drawRect(16,-4,4,8);
head.graphics.endFill();
head.graphics.beginFill(0,1);
head.graphics.drawRect(8,-8,4,4);
head.graphics.endFill();
head.x= 4;
head.y = -16;
neck.addChild(head);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var deb:TextField;
public var hip:Sprite;
public var body:Sprite;
public var arm:Sprite;
public var neck:Sprite;
public var head:Sprite;
public function onEnter(e:Event):void
{
var mx:Number; var my:Number;
var ang:Number;
mx = stage.mouseX; my = stage.mouseY;
//ang = Math.atan2(my-(body.y+arm.y), mx-(body.x+arm.x));
ang = Math.atan2(my-200+48, mx-200);
arm.rotation = (ang * (180/3.1415));
neck.rotation = (ang * (180/3.1415))*0.5;
head.rotation = (ang * (180/3.1415))*0.2;
body.rotation = (ang * (180/3.1415))*0.1;
hip.rotation = (ang * (180/3.1415))*0.1;
deb.text = " ang "+ang;
}//onenter
}//classend
}