I’m trying to simulate the coriolis effect and have managed to create a drawing application that lets the user draw on a rotating movie clip. However, I would like to now create an animation that automatically draws a line onto the movie clip which ends up being curved, but I can’t figure out how to convert the x, y coordinates of the pixels on the stage to the corresponding x, y values of the movie clip. Here’s what I have so far:
var rotSlow:Boolean = true;
var rotFast:Boolean = false;
var upperWhiteArrow:whiteArrow = new whiteArrow();
var lowerWhiteArrow:whiteArrow = new whiteArrow();
var counter:Number = 0;
var yspeed:Number = -1;
var canvas:MovieClip = new MovieClip();
var g:Graphics = canvas.graphics;
upperWhiteArrow.x = 27.8;
upperWhiteArrow.y = 552.3;
stage.addChild(upperWhiteArrow);
g.beginFill(0xffffff, 0);
g.drawRect(-250, -250, 500, 500);
g.endFill();
canvas.x = 300;
canvas.y = 300;
addChild(canvas);
var xpos:Number = this.x;
var ypos:Number = this.y + 250;
canvas.graphics.lineStyle(5, 0x000000);
canvas.graphics.moveTo(xpos, ypos);
stage.addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(event:Event):void {
if (ypos >= 0) {
ypos += yspeed;
canvas.graphics.lineTo(this.x, ypos);
}
if (rotSlow) {
canvas.rotation -= 0.2;
earth_mc.rotation -= 0.2;
} else if (rotFast) {
canvas.rotation -= 1;
earth_mc.rotation -= 1;
}
}
slow_btn.addEventListener(MouseEvent.MOUSE_DOWN, slowClicked);
function slowClicked(evt:MouseEvent):void {
rotFast = false;
rotSlow = true;
if (counter == 1) {
stage.removeChild(lowerWhiteArrow);
stage.addChild(upperWhiteArrow);
}
counter = 0;
}
fast_btn.addEventListener(MouseEvent.MOUSE_DOWN, fastClicked);
function fastClicked(evt:MouseEvent):void {
rotSlow = false;
rotFast = true;
if (counter == 0) {
stage.removeChild(upperWhiteArrow);
lowerWhiteArrow.x = 27.8;
lowerWhiteArrow.y = 571.8;
stage.addChild(lowerWhiteArrow);
}
counter = 1;
}