• Home
  • About Me
  • AIR Central
  • AS3 Libs
  • Books
  • Flex Central
  • Resources
  • The Guru's
  •  

    NativeAlertWindow

    Want to launch a toast style window within an AIR application that animates in the lower right corner of the screen? Try my AIR NativeAlertWindow component. It will animate itself rising from the lower right corner of the screen and delay for a predetermined amount of time that you set. It also has the ability to bounce. See the details below.
    eflex003.jpg

    Grab the SWC file here.

    The NativeAlertWindow constuctor accepts 7 arguments.

    1. public function NativeAlertWindow(title:String,message:String,delayTime:int=3,width:int=200,height:int=100,notify:Boolean=true,riseTo:int=0)

    The arguments:

    title:String - the title of the AlertWindow *required
    message:String - the message of the AlertWindow *required

    delayTime:int - the amount of time the window will remain in the up position, defaults to 3 seconds
    width:int - the width of the window, defaults to 200
    height:int - the height of the window, defaults to 100
    notify:Boolean - if delayTime is set to 0 and notify is set to true, the window will bounce until the user interacts with it
    riseTo:int - the y position in which the window will rise to, defaults to 0 which then will calculate the y position based on the window height and the overall screen height

    This sample creates a window that is 200 x 100, has the title “Alert” with the message “Something is Happening” and will rise up, delay 3 seconds, and then go back down.

    1. private function openAlert1():void{
    2.     aw1 = new NativeAlertWindow("Alert","Something is Happening");
    3.     aw1.activate();
    4. }

    This sample creates a window that is 300 x 200, has the title “Alert” with the message “Something is Happening” and will rise up, delay 5 seconds, and then go back down.

    1. private function openAlert2():void{
    2.     aw2 = new NativeAlertWindow("Alert","Something is Happening",5,300,200);
    3.     aw2.activate();
    4. }

    This sample creates a window that is 200 x 100, has the title “Alert” with the message “Something is Happening” and will rise up and remain until the user interacts with it.

    1. private function openAlert3():void{
    2.     aw3 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,false);
    3.     aw3.activate();
    4. }

    This sample creates a window that is 200 x 100, has the title “Alert” with the message “Something is Happening” and will rise up and bounce until the user interacts with it.

    1. private function openAlert4():void{
    2.     aw4 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,true);
    3.     aw4.activate();
    4. }

    This sample creates a window that is 200 x 100, has the title “Alert” with the message “Something is Happening” and will rise up to a y of 200 and then retreat after 3 seconds.

    1. private function openAlert5():void{
    2.     aw5 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,false,200);
    3.     aw5.activate();
    4. }

    Finally, here is the full sample code for this demonstration of the NativeAlertWindow component.

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    3.     <mx:Script>
    4.         <![CDATA[
    5.             import com.everythingflex.air.components.NativeAlertWindow;
    6.             private var aw1:NativeAlertWindow;
    7.             private var aw2:NativeAlertWindow;
    8.             private var aw3:NativeAlertWindow;
    9.             private var aw4:NativeAlertWindow;
    10.             private var aw5:NativeAlertWindow;
    11.            
    12.             private function openAlert1():void{
    13.                 aw1 = new NativeAlertWindow("Alert","Something is Happening");
    14.                 aw1.activate();
    15.             }
    16.            
    17.             private function openAlert2():void{
    18.                 aw2 = new NativeAlertWindow("Alert","Something is Happening",5,300,200);
    19.                 aw2.activate();
    20.             }
    21.            
    22.             private function openAlert3():void{
    23.                 aw3 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,false);
    24.                 aw3.activate();
    25.             }
    26.            
    27.             private function openAlert4():void{
    28.                 aw4 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,true);
    29.                 aw4.activate();
    30.             }
    31.            
    32.             private function openAlert5():void{
    33.                 aw5 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,false,200);
    34.                 aw5.activate();
    35.             }
    36.            
    37.         ]]>
    38.     </mx:Script>
    39.     <mx:Button click="openAlert1()" label="AlertWindow" x="163" y="110" width="200"/>
    40.     <mx:Button click="openAlert2()" label="AlertWindow 5 seconds (big)" x="163" y="140" width="200"/>
    41.     <mx:Button click="openAlert3()" label="AlertWindow permanent" x="163" y="170" width="200"/>
    42.     <mx:Button click="openAlert4()" label="AlertWindow notify" x="163" y="200" width="200"/>
    43.     <mx:Button click="openAlert5()" label="AlertWindow riseTo 200" x="163" y="230" width="200"/>
    44. </mx:WindowedApplication>