Search

 

February 2012
S M T W T F S
« Nov    
 1234
567891011
12131415161718
19202122232425
26272829  

Tags

Archives

NativeAlertWindow

By Rich Tretola | February 13, 2008
4,573 views

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
2
3
4
private function openAlert1():void{
    aw1 = new NativeAlertWindow("Alert","Something is Happening");
    aw1.activate();
}

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
2
3
4
private function openAlert2():void{
    aw2 = new NativeAlertWindow("Alert","Something is Happening",5,300,200);
    aw2.activate();
}

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
2
3
4
private function openAlert3():void{
    aw3 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,false);
    aw3.activate();
}

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
2
3
4
private function openAlert4():void{
    aw4 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,true);
    aw4.activate();
}

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
2
3
4
private function openAlert5():void{
    aw5 = new NativeAlertWindow("Alert","Something is Happening",0,200,100,false,200);
    aw5.activate();
}

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
            import com.everythingflex.air.components.NativeAlertWindow;
            private var aw1:NativeAlertWindow;
            private var aw2:NativeAlertWindow;
            private var aw3:NativeAlertWindow;
            private var aw4:NativeAlertWindow;
            private var aw5:NativeAlertWindow;

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

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

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

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

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

        ]]>
    </mx:Script>
    <mx:Button click="openAlert1()" label="AlertWindow" x="163" y="110" width="200"/>
    <mx:Button click="openAlert2()" label="AlertWindow 5 seconds (big)" x="163" y="140" width="200"/>
    <mx:Button click="openAlert3()" label="AlertWindow permanent" x="163" y="170" width="200"/>
    <mx:Button click="openAlert4()" label="AlertWindow notify" x="163" y="200" width="200"/>
    <mx:Button click="openAlert5()" label="AlertWindow riseTo 200" x="163" y="230" width="200"/>
</mx:WindowedApplication>