FlexのRIAアプリケーショントレイとQQリマインダ機能
FlexのRIAアプリケーショントレイとQQリマインダ機能
トレイ機能は、アプリケーションが最小化または閉じるときにウィンドウを非表示にし、アプリケーションをトレイに表示する、タスクバーに表示しない機能です.QQアラーム機能に似た実装もある.
AIRプログラムのWindowApplicationファイルのmxml;
次に、モードのHttpServiceリクエストのorder.xml
QQアラーム機能のPopMsg.mxml
トレイ機能は、アプリケーションが最小化または閉じるときにウィンドウを非表示にし、アプリケーションをトレイに表示する、タスクバーに表示しない機能です.QQアラーム機能に似た実装もある.
AIRプログラムのWindowApplicationファイルのmxml;
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApplication()">
<mx:Style source="css/CSS.css"/>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.UIComponent;
import mx.core.Container;
import mx.events.ItemClickEvent;
import mx.events.CloseEvent;
import flash.display.BitmapData;
import flash.errors.*;
import flash.events.*;
import flash.external.*;
import flash.desktop.NativeApplication;
private var dockImage:BitmapData;
// Application , :
public function initApplication():void{
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,prepareForSystray);// , prepareForSystray
loader.load(new URLRequest("png/systray_icon_16.png"));//
this.addEventListener(Event.CLOSING,closingApplication);//
}
//
public function closingApplication(event:Event):void{
event.preventDefault();//
Alert.yesLabel=" ";
Alert.noLabel=" ";
Alert.show(" ?", " ?", 3, this, alertCloseHandler);// , Alert , .
}
// , , (Mini) .
private function alertCloseHandler(event:CloseEvent):void{
if(event.detail==Alert.YES){
closeApp(event);
}else{
dock();//
}
}
//
public function prepareForSystray(event:Event):void{
dockImage=event.target.content.bitmapData;
if(NativeApplication.supportsSystemTrayIcon){
setSystemTrayProperties();//
SystemTrayIcon(NativeApplication.nativeApplication.icon).menu=createSystrayRootMenu();//
}
}
public function createSystrayRootMenu():NativeMenu{
var menu:NativeMenu = new NativeMenu();
var openNativeMenuItem:NativeMenuItem = new NativeMenuItem("Open");// OPEN
var exitNativeMenuItem:NativeMenuItem = new NativeMenuItem("Exit");//
openNativeMenuItem.addEventListener(Event.SELECT, undock);
exitNativeMenuItem.addEventListener(Event.SELECT, closeApp);// EXIT
menu.addItem(openNativeMenuItem);
menu.addItem(new NativeMenuItem("",true));//separator
menu.addItem(exitNativeMenuItem);//
return menu;
}
//
private function setSystemTrayProperties():void{
SystemTrayIcon(NativeApplication.nativeApplication.icon).tooltip = " ";
SystemTrayIcon(NativeApplication.nativeApplication.icon).addEventListener(MouseEvent.CLICK, undock);
stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING, nwMinimized);
}
//
private function nwMinimized(displayStateEvent:NativeWindowDisplayStateEvent):void {
if(displayStateEvent.afterDisplayState == NativeWindowDisplayState.MINIMIZED) {
displayStateEvent.preventDefault();//
dock();//
}
}
//
public function dock():void {
stage.nativeWindow.visible = false; //
NativeApplication.nativeApplication.icon.bitmaps = [dockImage];//
}
//
public function undock(evt:Event):void {
stage.nativeWindow.visible = true;//
stage.nativeWindow.orderToFront();//
NativeApplication.nativeApplication .icon.bitmaps = [];//
}
//
private function closeApp(evt:Event):void {
stage.nativeWindow.close();
}
public function about():void{
Alert.okLabel=" ";
Alert.show("JODY
JODY , 。");
}
public function infos():void{
var popUp:PopMsg=new PopMsg();
popUp.systemChrome=NativeWindowSystemChrome.NONE;
popUp.transparent=true;
popUp.showTitleBar=false;
popUp.showStatusBar=false;
popUp.open();
popUp.init();
}
public function getOrderInfos():void{
srv.send();
infos();
}
]]>
</mx:Script>
<mx:ApplicationControlBar width="98%" top="0" horizontalCenter="1" height="59" fillAlphas="[1.0, 1.0]" fillColors="[#2F58F1, #2F58F1]" color="#FBFDFE" verticalAlign="middle">
<mx:ControlBar height="49" width="100%" horizontalAlign="left" verticalAlign="middle">
<mx:Image source="png/logoicon.png" autoLoad="true" width="32" height="32"/>
<mx:Label text=" " fontWeight="bold" fontFamily="Verdana" fontSize="14"/>
<mx:Spacer width="100%"/>
<mx:Button id="f5order" label=" " cornerRadius="12" color="0xffffff" fillColors="[0x55C0FF,0x0050AA]" fillAlphas="[1.0,1.0]" highlightAlphas="[1.0,0.2]" focusAlpha="0.2"
textRollOverColor="0xffffff" textSelectedColor="0x55C0FF" click="getOrderInfos()" labelPlacement="right"/>
<mx:Button id="aboutinfo" label=" " cornerRadius="12" color="0xffffff" fillColors="[0x55C0FF,0x0050AA]" fillAlphas="[1.0,1.0]" highlightAlphas="[1.0,0.2]" focusAlpha="0.2"
textRollOverColor="0xffffff" textSelectedColor="0x55C0FF" click="about()" labelPlacement="right"/>
</mx:ControlBar>
</mx:ApplicationControlBar>
<mx:HTTPService id="srv" url="order.xml"/>
<mx:Panel width="98%" height="90%" layout="absolute" horizontalCenter="1" top="67" title=" ">
<mx:DataGrid dataProvider="{srv.lastResult.orders.order}" width="100%" horizontalCenter="0" top="0" height="80%">
<mx:columns>
<mx:DataGridColumn headerText=" " dataField="id"/>
<mx:DataGridColumn headerText=" " dataField="orderId"/>
<mx:DataGridColumn headerText=" " dataField="orderfor"/>
<mx:DataGridColumn headerText=" " dataField="amout"/>
<mx:DataGridColumn headerText=" " dataField="status"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:WindowedApplication>
次に、モードのHttpServiceリクエストのorder.xml
<?xml version="1.0" encoding="utf-8"?>
<orders>
<order orderId="D10001">
<id>1</id>
<orderfor>Web </orderfor>
<amout>210</amout>
<status> </status>
</order>
<order orderId="D10002">
<id>2</id>
<orderfor>Wap </orderfor>
<amout>310</amout>
<status> </status>
</order>
<order orderId="D10003">
<id>3</id>
<orderfor>SMS </orderfor>
<amout>410</amout>
<status> </status>
</order>
</orders>
QQアラーム機能のPopMsg.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Window xmlns:mx="http://www.adobe.com/2006/mxml" width="300" height="200">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
//
private var Timer1:Timer=new Timer(1);
//
private var Timer2:Timer=new Timer(8000,1);
//
private var Timer3:Timer=new Timer(1);
private var _x:uint=0;
private var _y:uint=0;
private var _height:uint=0;
private var screenBounds:Rectangle;
public function init():void{
this.startPosition();
this.Timer1.addEventListener(TimerEvent.TIMER,scorllUp);
//this.colseBtn.addEventListener(MouseEvent.CLICK,closeApp);
this.Timer1.start();
}
/**
*
*/
private function scorllUp(e:TimerEvent):void{
if(this._height<200){
this._height++;
this.setLocation(this._x,this._y-30-this._height);
}
else{
this.Timer2.addEventListener(TimerEvent.TIMER,wait);
this.Timer2.start();
this.Timer1.stop();
}
}
/*
* y
*
*/
private function setLocation(x:uint,y:uint):void{
this.nativeWindow.y=y;
this.nativeWindow.x=x;
//trace(x+'='+y);
}
private function wait(e:TimerEvent):void{
this.Timer3.addEventListener(TimerEvent.TIMER,scorllDown);
this.Timer3.start();
}
private function scorllDown(e:TimerEvent):void{
try{
if(this.Timer2!=null){
this.Timer2.stop();
this.Timer2=null;
}
if(this._height>0){
this._height--;
//trace(this._height);
this.setLocation(this._x,this.nativeWindow.y+1);
//trace(this.nativeWindow.y);
}
else{
this.Timer3.stop();
this.close();
}
}catch(error:Error){
Alert.show(" "+error.message);
}
}
/*
*
*/
public function startPosition():void{
this.screenBounds=Screen.mainScreen.bounds;
//trace(this.screenBounds);
this._x=this.screenBounds.width- 300;
//trace(this._x);
this._y=this.screenBounds.height;
//trace(this._y);
this.nativeWindow.x=this._x;
this.nativeWindow.y=this._y;
}
private function closeApp(e:MouseEvent):void{
this.close();
}
public function closes():void{
this.close();
}
]]>
</mx:Script>
<mx:TitleWindow title=" " titleIcon="@Embed(source='png/systray_icon_16.png')" width="100%" height="100%" layout="absolute">
<mx:Label text=" , 。
。" width="179" height="111"/>
</mx:TitleWindow>
</mx:Window>