Category Archives: Snippets

Center/Align Vertically Text in a TextField Control

Depending whether you are using the classic TextField control and the TLFTextField newly introduced in Flash 10, you can choose one of the following options:

If we are using an TLFTextField instead of the classic TextField, it’s getting easier, because we have the vertical align feature implemented by the… Read more »

Shuffle/Randomize Array/Vector in AS3

As3 Array/Vector classes don’t provide an implemented method to shuffle/randomize them. However, that’s not a hard task to do and there are quite a few methods to implement such an algorithm. One of the easiest methods is called Fisher-Yates shuffle. Probably it’s not the fastest way to shuffle an array,… Read more »

Bounding Box of a Rotated Rectangle

      No Comments on Bounding Box of a Rotated Rectangle

In action script is possible to find out the bounding box of a rotated sprite(rectangles can be used as well) using DisplayObject.getBounds method. In this post I’ll show a pure mathematic/geometrical approach. It has the advantages that can be ported in other languages, can be used independently of AS3 display… Read more »

Add Auto-Hide functionality to Sprite and MovieClip objects in AS3

Auto-Hide might be useful when you deal with situations when you have too many controls on a screen and you just want to hide those which are not used so often to have enough space in the main screen. A simple option to implement would be to use MouseEvent.MOUSE_OVER and… Read more »

How to add Drag’n Drop functionality to a Sprite

      No Comments on How to add Drag’n Drop functionality to a Sprite

Here is a little snippet code which adds drag and drop functionality to a sprite object:

How to Use net.hires.debug.Stats to Test the Performance

Download the net.hires.debug.Stats class and copy it in your application source code structure. add a new object to the main sprite object:

If you prefer different colors you can add some custom parameters: