IntroductionThis page contains a quick overview of how the library can be used. The as3growl library is an ActionScript library that leverages new TCP socket communication functionality within the Growl notification framework to allow Adobe AIR and Flash applications to register with, send notifications, and receive events from the Growl service. Using the ServiceIn order to send a notification, you must follow these steps: - Create an instance of the GrowlService class, passing in an Application instance that represents the application that will be communicating with the Growl service.
- Connect to the Growl service by calling connect() and passing the NotificationTypes that the applicaiton will be sending.
- Register for and listening for appropriate events broadcast by the GrowlService
- Send notifications by calling notify() and passing in a Notification instance. Note that the Notification instance name must match the name of a previously registered NotificationType.
Here is a simple snippet that shows connecting to the service and sending a notification: import com.adobe.growl.Application;
import com.adobe.growl.GrowlService;
import com.adobe.growl.Header;
import com.adobe.growl.Notification;
import com.adobe.growl.NotificationType;
import com.adobe.growl.events.GrowlResponseEvent;
import flash.filesystem.File;
import flash.events.IOErrorEvent;
import flash.errors.IOError;
private var g:GrowlService;
private var a:Application;
private var nt:com.adobe.growl.NotificationType;
private function onApplicationComplete():void
{
a = new Application();
a.name = "MESH";
//can be file:// or http:// path
a.iconPath = new File(new File("app:/icon.png").nativePath).url;
nt = new com.adobe.growl.NotificationType();
nt.enabled = true;
nt.name = n.name;
nt.displayName = "Notification Display Name";
g = new GrowlService(a);
//broadcast if error connecting to service
g.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
//broadcast when a notification is clicked
g.addEventListener(GrowlResponseEvent.NOTIFICATION_CLICK, onNotificationClick);
g.connect([nt]);
}
private function onIOError(e:IOErrorEvent):void
{
trace("IOError");
}
private function onNotificationClick(e:GrowlResponseEvent):void
{
trace("Notification Clicked : " + e.notificationId);
}
//send a notification
private function onNotify():void
{
var n:Notification = new Notification();
n.name = "Foo Name";
n.title = "This is the title.";
n.text = "This is the notification text";
n.sticky = false;
n.iconPath = a.iconPath;
g.notify(n);
}Please view the API docs included in the library download to view all of the events broadcast by the GrowlService class.
|
I've been getting onSocketIOError : Error #2031: Socket Error. URL: 127.0.0.1. Growl installed and running. Did notice the class looks for port 23053 and the preferences on my growl show 23052 for network comms. Is that related?
If you try and pass in the other port (23052) into the GrowlService? constructor, does it work?
Do you have something running already on port 23053.
Mike, yes - 23052 works! I guess we can just always go change that to make it work. I just wondered how that might affect a deployed app. Thanks.
This might be a bug. Ill look into it.
Hello, thank you for this package Mike,
It works for me with port 23053, I really passed 3-4hours before make it works. Because i didn't see that the nightly version of growl was required. And i didn't see that was the xml file "GrowlTest?-app.xml" was containing xmlns="http://ns.adobe.com/air/application/1.5", i tried to find the AIR PLAYER 1.5 (COSMO) but i didn't success so i replaced 1.5 by 1.1 :) Does adobe provide a link to download Adobe AIR 1.5 ? (I could update the Flex SDK with the last one which contains the Adobe AIR SDK 1.5)
Why the old version of growl could not communicate with Flash ?
Thanks you again :) It enables to make a lot of things, i notably think about social applications over the net, (but limited by the crossdomain.xml which needs to be send to flash application before establishing communication).
>Why the old version of growl could not communicate with Flash ?
It doesnt have support for the new functionality.
Sorry about the hassle. The functionality will evetually be in the release build.
Ok :)
I've some questions about register mechanism :
does Adobe provide the AIR Player 1.5 ?
Thank you again Mike :)
Please post any questions about the project to the project list:
http://groups.google.com/group/as3growl
and any issues to the issue tracker:
http://code.google.com/p/as3growl/issues/list