flash on 2012-3-30
♥0 |
Line 34 |
Modified 2012-03-30 18:25:47 |
MIT License
archived:2017-03-30 02:56:09
ActionScript3 source code
/**
* Copyright tepe ( http://wonderfl.net/user/tepe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8Jrp
*/
package {
import flash.display.Sprite;
import flash.geom.*;
import flash.text.*;
import flash.events.*;
public class FlashTest extends Sprite {
private var s1:Sprite = new Sprite();
private var field:Sprite = new Sprite();
public function FlashTest() {
// write as3 code here..
addChild(field);
field.x = 100;
field.y = 100;
field.addChild(s1);
s1.graphics.beginFill(0x000000);
s1.graphics.drawCircle(0,0,10);
s1.graphics.endFill();
s1.x = 20;
s1.y = 20;
addEventListener(Event.ENTER_FRAME,onEnter);
}
private function onEnter(e:Event):void{
var pt:Point = new Point(s1.x,s1.y);
pt = Rotate2(pt,0.1);
s1.x = pt.x;
s1.y = pt.y;
}
private function Rotate2(pt1:Point,alpha:Number):Point{
var pt2:Point = new Point();
pt2.x = pt1.x * Math.cos(alpha) - pt1.y * Math.sin(alpha);
pt2.y = pt1.x * Math.sin(alpha) + pt1.y * Math.cos(alpha);
return pt2;
}
}
}