Positioning after stage resize

Hi there,

I’m a little confused with coordinates in flash, particularly after resizing the flash player window.

I have an mc on stage and draw an ellipse inside that mc. The movie is of size 800 x 600.


var ellipse:Shape = new Shape();
ellipse.graphics.beginFill(0x6CCDF4, 0.5);
ellipse.graphics.lineStyle(4,0x186B87);
ellipse.graphics.drawEllipse(0, 0, 100, 100);
ellipse.graphics.endFill();
join.canvas.addChild(ellipse);

If I check the coordinates of that ellipse from it’s transform property, I see that the top left is at 400, 300.

ellipse.transform.pixelBounds.topLeft.x
ellipse.transform.pixelBounds.topLeft.y

This seems fine to me as this position is in relation to the stage, yes? If I convert this to a position local to the container I get values ~0,0.

var stagePoint:Point = new Point(ellipse.transform.pixelBounds.topLeft.x, ellipse.transform.pixelBounds.topLeft.y);
var localPoint:Point = join.canvas.globalToLocal(stagePoint);

When the flash player window is resized, the coordinates change entirely. Instead of being at 400,300 the transform property indicates that it is at 640, 510. I assume this is because the viewport has changed, but the stageWidth and width properties of the stage do not change.

Is there a better way of finding the position of the ellipse to avoid this? Or is there a way for me to calculate this change?

Thanks,

Baps.