AlertBox

Package:
Class:
Inheritance:
biz.flashscript.components.alert
public class AlertBox
Sprite
The AlertBox class is used for an Alert component. To create an instance of the AlertBox use the constructor new AlertBox(). Options exist to make use of a "Yes" and "No" button for decision making.
Public Properties
Property Defined By
myBlur : int
Will cause blurring of the background.
AlertBox
myLabel : String
The label shown in the component instance.
AlertBox
positionx : int
The x position of the component instance.
AlertBox
positiony : int
The y position of the component instance.
AlertBox
textCol : uint
The color of the label.
AlertBox
textFormat : TextFormat
The TextFormat for the label.
AlertBox
textFnt : Font
The Font class for the label. Create a Font class.
AlertBox
yes_noAlert : Boolean
Whether a the yes-no buttons will be shown.
AlertBox
Public Methods
Method Defined By
AlertBox()
Creates a new instance of the AlertBox component.
AlertBox
callAlert()
Function is used to activate the alert.
AlertBox
Events
Event Defined By
All inherited events for the Sprite class.

yesHandler

This event is dispatched when the yes button is pressed.

AlertBox

noHandler

This event is dispatched when the no button is pressed.

AlertBox
Property Detail
myBlur property
myBlur:int [read-write]

Setting a value will cause blurring depending on the value.

The default value is 0.

.

Implementation

public function get myBlur():int
public function set myBlur(value:int):void

myLabel property
myLabel:String [read-write]

This defines the label for the AlertBox component.

The default value is defaulValue.

.

Implementation

public function get myLabel():String
public function set myLabel(value:String):void

positionx property
positionx:int [read-write]

This is the x position for the AlertBox component. If it is 0 the x position of the component instance will be automatically the center of the stage.

The default value is 0.

Implementation

public function get positionx():int
public function set positionx(value:int):void

positiony property
positiony:int [read-write]

This is the y position for the AlertBox component. If it is 0 the y position of the component instance will be automatically the center of the stage.

The default value is 0.

Implementation

public function get positiony():int
public function set positiony(value:int):void

textCol property
textCol:uint [read-write]

This defines the textcolor for the label.

The default value is 0x000000.

Implementation

public function get textCol():uint
public function set textCol(value:uint):void

textFormat property
textFormat:TextFormat [read-write]

This will implement a new textformat for the label.

The default value is the Flash TextFormat default format.

Implementation

public function get textFormat():TextFormat
public function set textFormat(value:TextFormat):void

textFnt property
textFnt:Font [read-write]

This will implement a new Font for the TextFormat.

The default value is null.

Implementation

public function get textFnt():Font
public function set textFnt(value:Font):void

yes_noAlert property
yes_noAlert:Boolean [read-write]

If set to true the AlertBox instance will have two buttons. There is no function associated with the buttons.

The default value is 0.

Implementation

public function get yes_noAlert():Boolean
public function set yes_noAlert(value:Boolean):void

See also

   biz.flashscript.components.alert.CallAlert

Constructor Detail
AlertBox ()  Constructor
public function AlertBox()
Intializes a new AlertBox instance.
Method Detail

callAlert()  method
public function callAlert():void

This method will activate an alert.

Event Detail

yesHandler event

Event Object Type: biz.flashscript.components.alert.AlertBox
Event.type property = biz.flashscript.components.alert.AlertBox.YES_HANDLER

Dispatched when the yes button is pressed.

noHandler event

Event Object Type: biz.flashscript.components.alert.AlertBox
Event.type property = biz.flashscript.components.alert.AlertBox.NO_HANDLER

Dispatched when the no button is pressed.

Examples
Create a new Actionscript 3 file and name it Alert_test.as. Place the script below in the file. Create a new fla file and name it Alert_test.fla. Place the AlertBox component in the library. Choose Arial Narrow and embed all fonts. Place any objects on the main timeline and also a CustomButton component and name it callAlert. Name the font and font class "ArialNarrow". Press the button and you should see an AlertBox instance popping up and the background blurred.
package 
{
	import biz.flashscript.components.alert.AlertBox;
	import flash.events.*;
	import flash.display.Sprite;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	import flash.text.Font;
	import biz.flashscript.components.buttons.CustomButton;

	//
	public class Alert_test extends Sprite
	{
		public var callAlert:CustomButton;
		private var myAlert:AlertBox;
		
		public function Alert_test ():void
		{
			callAlert.label = "Call Alert";
			callAlert.addEventListener(MouseEvent.CLICK, callHandler);
			
			var myFont:Font = new ArialNarrow ();
			var format:TextFormat = new TextFormat  ;
			format.align = TextFormatAlign.CENTER;
			format.font = myFont.fontName;
			format.size = 20;

			myAlert = new AlertBox  ;
			myAlert.myBlur = 20;
			myAlert.textFormat = format;
			myAlert.textFnt = myFont;
			myAlert.textCol = 0xFFFFFF;
			myAlert.yes_noAlert = true;
			addChild (myAlert);
			myAlert.scaleX = 1.5;
			myAlert.scaleY = 1.5;
			myAlert.addEventListener(AlertBox.YES_HANDLER,yesAlert);
			myAlert.addEventListener(AlertBox.NO_HANDLER,noAlert);
		}
		private function callHandler (ev:Event):void
		{
			myAlert.myLabel = "This is working well right now!";
			myAlert.callAlert();
		}
		private function yesAlert (ev:Event):void
		{
			trace ("YES!");
		}
		private function noAlert (ev:Event):void
		{
			trace ("NO!");
		}
	}
}
Get Adobe Flash player