New Proxy Component in UcompOS SDK: UcompOSAlertProxy

This morning, I have just added a new Proxy Component to the UcompOS SDK: UcompOSAlertProxy that is available in version 0.2.2 and later of the UcompOS Developers Package.

UcompOSAlertProxy provides a way to create a modal dialogue on the UcompOS Portal via an implementation of the Flex Alert control.

Previously, I had made this possible with the createAlert(); method of the SDK class UcompOSGlobalManagerProxy.

The inefficiency with this is that UcompOSGlobalManagerProxy is a Singleton class (along with UcompOSDockProxy, UcompOSMenuBarProxy, and UcompOSStyleProxy).  So one instance of UcompOSGlobalManagerProxy would handle the event dispatching for all Alert dialogues created with its createAlert(); method.

So handling events dispatched by Alerts created with UcompOSGlobalManagerProxy‘s createAlert(); method required extra handling and actually provided risks of gaps in data integrity and continuity.

I have removed the createAlert(); from UcompOSGlobalManagerProxy and replaced the functionality with the simpleAlert(); and confirmAlert(); methods of the UcompOSAlertProxy class.

The simpleAlert(); method launches a simple Alert with a single control button that will default with a label of “OK”.

The signature of simpleAlert(); is as follows:

public function simpleAlert(title:String, message:String, okLabel:String="OK"):void

You have the ability to customize the label on the single button presented on the Alert control.

The signature of confirm(); is as follows:

public function confirm(title:String, message:String, okLabel:String = null,
cancelLabel:String = null, defaultButton:String="OK"):void

You can specify the labels to be used on both the OK and Cancal buttons and you can articulate which should be the default button.

When the user takes action and clicks a button on the Alert dialogue, an instance of SDKEvent is dispatched by the UcompOSAlertProxy instance of type UcompOSAlertProxy.ALERT_SUBMIT.

The SDKEvent instance’s data property will have a detail property of type String which will have a value of UcompOSAlertProxy.OK or UcompOSAlertProxy.CANCEL.

Let’s look at a very simple example with the aid of some code:

private function fileExists(file:String):void
{
 var a:UcompOSAlertProxy = new UcompOSAlertProxy();
 a.data = file;
 a.addEventListener(UcompOSAlertProxy.ALERT_SUBMIT,fileExists_handler);
 a.confirm("A file named "+file+" exists in the target location. 
 Do you wish to overwrite it?","Yes","No",UcompOSAlertProxy.CANCEL);
}
 
private function fileExists_handler(event:SDKEvent):void
{
 var a:UcompOSAlertProxy = event.proxyComponent as UcompOSAlertProxy;
 if(event.data.detail==UcompOSAlertProxy.OK)
 {
 trace("Overwrite file "+a.data);
 }
 
}

About Edward Mansouri
Edward Mansouri is the CEO and Founder of Ucompass.com, Inc., a company focused on building scalable and profitable e-Learning enterprises. His expertise is in building e-Learning software, as well as in building visual frameworks such as the Enrich Content Enrichment System and the newly announced UcompOS Rich Experience Framework. He has been working with Flash since 1998, building Flash applications since 2002, and working with Adobe AIR since its private alpha release in 2006. He authored the site AIRApps.net (later renamed to O2Apps.com) dedicated to providing leadership in building Adobe AIR applications. In 2010, he is building and releasing a new e-Learning platform called Educator 2 which is built entirely upon the UcompOS Rich Experience Framework. Since 1999, over 1,000,000 students have taken courses served with his original e-Learning platform, Educator 1.

Comments are closed.