Reputation: 3496
I'm brand new to AS3, and I'm using Shape and Sprite objects in the browser and playing with some animation. The first thing I noticed is that if my browser is wider than about 725 pixels, objects at (0,0) start to the right but stay along the top edge. If the browser is narrower than about 725 pixels, objects at (0,0) stick to the left edge but move down the page and get smaller.
What's going on here? My understanding is that 'drawRect(0,0,50,50)' should make a 50px by 50px square in the top left corner. I changed the color of the stage so I could make sure that it is not moving, and it is not...the shapes are moving within the stage.
Here is an example:
package
{
import flash.display.Shape;
import flash.display.Sprite;
public class Game extends Sprite
{
public function Game()
{
stage.color = 0xAAAAAA;
var shape:Shape = new Shape();
shape.graphics.beginFill(0x000000,1);
shape.graphics.drawRect(0,0,50,50);
shape.graphics.endFill();
stage.addChild(shape);
}
}
}
Any help is greatly appreciated! I'm just looking to understand what is happening and how to "lock down" the page so coordinates and sizes will be measured in constant pixels relative to the stage.
I captured a .GIF just to make sure you knew what I was talking about...sorry it's in fast motion for some reason, but it should get the point across: http://s17.postimg.org/m7j02pswf/Cropper_Capture_5.gif
Upvotes: 0
Views: 149
Reputation: 2649
Try adding these two lines:
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.color = 0xAAAAAA;
Upvotes: 2