# Converting x, y values

**URL:** https://forum.kirupa.com/t/converting-x-y-values/279295
**Category:** flash
**Created:** [January 13, 2009, 12:10am UTC](https://forum.kirupa.com/t/converting-x-y-values/279295 "2009-01-13T00:10:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![humus\_80](https://avatars.discourse-cdn.com/v4/letter/h/f4b2a3/32.png) [@humus\_80](https://forum.kirupa.com/u/humus_80)
#### Post date: [January 13, 2009, 12:10am UTC](https://forum.kirupa.com/t/converting-x-y-values/279295/1 "2009-01-13T00:10:42Z")

</div>

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:

```auto

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;
}

```
