Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
117 lines (96 sloc) 3.24 KB
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
title="Bouncy"
creationComplete="initializeApplication()">
<mx:Script>
<![CDATA[
import flash.utils.*
import flash.media.*;
import flash.desktop.DockIcon;
import flash.desktop.NativeApplication;
import flash.display.NativeWindow;
import mx.controls.Alert;
import com.adobe.air.notification.Notification;
import com.adobe.air.notification.Purr;
import flash.events.*;
import flash.net.XMLSocket;
/* Alert */
public var myAlert:Alert;
/* Sound */
[Embed(source="assets/sounds/Cartoon Boing.mp3")]
[Bindable]
private var sndCls:Class;
private var snd:Sound = new sndCls() as Sound;
/* Purr */
private var purr:Purr;
private var notificationIcon:Bitmap;
[Bindable]
[Embed(source="assets/icons/error.png")]
private var alertIcon:Class;
private function initializeApplication():void
{
this.notificationIcon = new alertIcon();
this.purr = new Purr(15);
/* XML Socket */
var xmlsock:XMLSocket = new XMLSocket();
xmlsock.connect("127.0.0.1", 5001);
xmlsock.addEventListener(DataEvent.DATA, onData);
xmlsock.addEventListener(Event.CONNECT, getConn)
}
private function startTimer():void
{
var intervalId:uint = setTimeout(displayNotification, delay.value*1000);
}
private function onData(event:DataEvent):void
{
/*myAlert = Alert.show(event.data, event.type, Alert.OK)*/
myAlert = Alert.show('Data', 'Data', Alert.OK)
}
private function getConn(event:Event):void
{
myAlert = Alert.show('Connection', 'Connection', Alert.OK)
}
private function displayNotification():void
{
playSound();
displayAlert();
displayPurr();
}
private function playSound():void
{
this.snd.play();
}
private function displayAlert():void
{
myAlert = Alert.show(message.text, "Notification after " + delay.value + " seconds", Alert.OK)
myAlert.height = 115;
myAlert.width = 200;
}
private function displayPurr():void
{
this.purr.alert(NotificationType.CRITICAL, this.nativeWindow);
var n:Notification = new Notification("Alert", this.message.text, null, 5, this.notificationIcon);
n.width = 200;
this.purr.addNotification(n);
navigateToURL(new URLRequest('http://www.google.com'));
}
]]>
</mx:Script>
<mx:Style source="style.css" />
<mx:VBox width="100%" height="100%" verticalAlign="middle" horizontalAlign="center" verticalGap="0">
<mx:Text width="100%" text="Bouncy" styleName="header" />
<mx:Form width="100%">
<mx:FormItem label="Notify after (seconds)">
<mx:NumericStepper id="delay" value="2" stepSize="1" maximum="10"/>
</mx:FormItem>
<mx:FormItem label="Notification Message:" width="100%">
<mx:TextInput id="message" width="100%"/>
</mx:FormItem>
</mx:Form>
<mx:HBox>
<mx:Button id="bouncer" label="Set notification" click="startTimer()"/>
</mx:HBox>
</mx:VBox>
</mx:WindowedApplication>
Something went wrong with that request. Please try again.