flash on 2011-3-17
♥0 |
Line 55 |
Modified 2012-05-04 05:58:30 |
MIT License
archived:2017-03-20 02:26:47
ActionScript3 source code
/**
* Copyright baudon.thomas ( http://wonderfl.net/user/baudon.thomas )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vxyz
*/
package {
import flash.events.Event;
import flash.display.Shape;
import flash.display.Sprite;
public class FlashTest extends Sprite {
private var truc:Shape;
private var truc2:Shape;
private var truc3:Shape;
private var t:Shape;
public function FlashTest() {
// write as3 code here..
truc = new Shape();
truc.graphics.beginFill(0x0000ff);
truc.graphics.drawRect(0,0,20,20);
truc.graphics.endFill();
addChild(truc);
truc2 = new Shape();
truc2.graphics.beginFill(0xff0000);
truc2.graphics.drawRect(0,0,20,20);
truc2.graphics.endFill();
addChild(truc2);
truc3 = new Shape();
truc3.graphics.beginFill(0x00ff00);
truc3.graphics.drawRect(0,0,20,20);
truc3.graphics.endFill();
addChild(truc3);
t = new Shape();
t.graphics.beginFill(0xffcc00);
t.graphics.drawRect(0,0,20,20);
t.graphics.endFill();
addChild(t);
stage.addEventListener(Event.ENTER_FRAME, update);
}
public function update(evt:Event):void
{
truc.x = stage.stageWidth/2 ;
truc.y = stage.stageHeight/2 ;
truc.rotation++;
truc2.x = truc.x;
truc2.y = truc.y;
truc2.x += Math.cos(truc.rotation/180*Math.PI - 0.5*Math.PI)*20;
truc2.y += Math.sin(truc.rotation/180*Math.PI - 0.5*Math.PI)*20;
truc2.rotation = truc.rotation;
truc3.x = truc2.x;
truc3.y = truc2.y;
truc3.rotation = truc2.rotation;
truc3.x += Math.cos(truc2.rotation/180*Math.PI)*20;
truc3.y += Math.sin(truc2.rotation/180*Math.PI)*20;
var X:Number = 20;
var Y:Number = 40;
t.x = Math.cos(truc3.rotation/180*Math.PI)*X - Math.sin(truc3.rotation/180*Math.PI)*Y + truc3.x;
t.y = Math.sin(truc3.rotation/180*Math.PI)*X + Math.cos(truc3.rotation/180*Math.PI)*Y + truc3.y;
t.rotation = truc3.rotation;
}
}
}