Saturday, October 13, 2012

AdvAlert AS3 class - Download and How To Use: Part 2

In this part I will show you how to stylize and customize your alert windows.

Adjusting the size and position of alert windows:

AdvAlert class is made with flexibility in mind. The alert windows are made to be stretchable both vertically and horizontally, depending on the size of provided text. There are limits to how wide or tall the windows can become - those can be defined by the developer to each window individually, or to all windows by default. But it is also possible to set strict height and width of a window.

To set default width and height of all alert windows, set the defaultWidth and defaultHeight parameters of AdvAlertManager object when creating an instance:

AlertManager = new AdvAlertManager(this, stage, null, null, null, true, 400, 0);

When height is set to 0, the window stretches veritcally depending on the text size.

You can set width and height of an alert window individually when calling alert() method. These values overwrite any default values specified by the AdvAlertManager object.

AlertManager.alert("Simple message!", "Title", null, 0, null, 400, 0);

By default, all windows spawn centered. You can change position of an individual window by providing a Point object as a parameter in the alert() method (best used when strict width and height are set):

AlertManager.alert("Simple message!", "Title", null, 0, null, 400, 140, new Point(50, 50));

You can set default minHeight, maxHeight and maxWidth values for all alert windows in AdvAlertManager constructor. When these are set, the window will not stretch out of the specified bounds.

It should be noted that alert windows are stretched vertically as much as possible to fit all the inner text. If that is not enough, it also stretches horizontally, until all text is displayed or until the sizes of the window reach maxWidth limit.

AlertManager = new AdvAlertManager(this, stage, null, null, null, true, 200, 0, 120, 400, 500);

You can set all these values individually too:

AlertManager.alert("Simple message!", "Title", null, 0, null, 200, 0, null, 120, 400, 500);

If you do not wish for a window to be able to stretch horizontally, you can turn off that feature by setting horizontalStretch parameter of alert() to false.

AlertManager.alert("Simple message!", "Title", null, 0, null, 200, 0, null, 120, 400, 500, false);

Add alert sound effects:

You can set a Sound effect to play when an alert window pops up.

To do this, either set a default value in the AdvAlertManager object constructor, or provide it to an individual alert window using alert() method:

AlertManager = new AdvAlertManager(this, stage, null, null, mySound);

AlertManager.alert("Simple message!", "Title", null, 0, null, 200, 0, null, 120, 400, 500, false, mySound);

Next time I will explain how skinning works in AdvAlert windows.

Thanks for reading!

No comments:

Post a Comment