Just make the Rectangle instance the same dimensions as the stage.
ie: var bounds:Rectangle = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
Everything else is essentially the same.
The rectangle is included here to illustrate the usefulness of the Rectangle class for doing stuff like this. ie: Rectangle has convenient left, right, bottom, top properties as well as a host of useful methods.
BTW, notice that there are virtually no hard-coded numeric properties in this code, which makes it more flexible and universal than using the numbers 900 and 575 to describe the stage boundaries. For all intents and purposes, the actual dimensions of the stage are irrelevant.
One other thing: be sure your concept of the stage is correct.
There is only one Stage instance. The stage dimensions are set in the FLA in the properties panel, along with the stage background color and document frameRate.
Flash Player instance
--Stage instance
----Document Class instance
------stuff you create in Flash
Last edited by [afz]snickelfitz; 08-07-2012 at 05:18 AM.
|