Did you notice that the new version of Actionscript has a new method: the getBounds?
This method is implemented in the DisplayObject Class and so, it can be used from the MovieClip and Sprite Class (as they inherit from the DisplayObject).
The method getBounds requires a parameter named targetCoordinateSpace that indicates which DisplayObject to use and defines the coordinates to be used (local or global).
It returns an instance of Rectangle with the properties x, y, width, height, left etc, etc… of the object associated to this method.
Often, it is required to position some objects in relation to the position of some other objects and it is then necessary to do some mathematical calculi.
In this case, the method getBounds will simplify our task to do so.
Let us see how to use it…










{ 0 comments… add one now }