Posts Tagged ‘air’

Air基本设置

// December 31st, 2008 // No Comments » // AIR实践

#.隐藏标题栏
先把#-app.xml中的标签值设置成none
么mxml里设置showTitleBar=”false”

#.隐藏状态栏
showStatusBar=”false”

#.NativeWindow类的常用方法:
最大化:maximize() ;
恢复: restore();
最小化:minimize() ;
关闭:close();
拖动窗口:startMove();
改变大小:startResize();
置前:alwaysInFront = true / false

#.Flex中AIR透明背景
1.打开同名app.xml
2.修改none
3.修改
true 4.设置WindowedApplication中showFlexChrome=”false”

#.自动启动
NativeApplication.nativeApplication.startAtLogin = true;

自动配置和在线安装Adobe AIR运行环境(AIR Express Install Badge )

// December 12th, 2008 // No Comments » // AIR实践

接触Adobe AIR的朋友一定会有这样一个疑惑:

如果客户的电脑上没装Adobe AIR运行环境怎么办?

事实上,我们明白,在Adobe AIR普及率还不算高的今天(尤其在中国)总是告诉客户“请先下载Adobe AIR1.1”会显得太不“友好”。因为可能网友们一时半会还没明白“AIR”是什么,我为什么要安装这个东西?

现在给大家介绍来自Adobe的解决方案:AIR Express Install Badge

如果你需要发布一个Adobe AIR应用,没有安装Adobe AIR运行环境的客户机它会为你自动地先安装Adobe AIR运行环境,然后再安装Adobe AIR应用。当然已经安装了AIR运行环境的就会直接安装AIR应用了. 这种在线安装AIR的方法很方便。

AIR Express Install Badge 事实上是一种Adobe AIR推出的“在线安装”AIR应用的方式。

怎样创建一个Adobe AIR应用在线安装?(步骤和下载):

  • 首先需要下载和配置AIR SDK     [ 下载1(AIR at WIN)下载2 (AIR at mac)更多SDK AIR Flash开发中心 ]
  • 然后需要创建一个在线安装时用的图片
  • 接着可以使用Flash来创建一个安装动画

简而言之,这个方法就是使用一个Flash动画作为在线安装的前端(因为FLASH的普及率是相当高的),这个时候通过FLASH来判断客户端是否 有Adobe AIR运行环境,如果没有则自动先安装Adobe AIR运行环境(当然时间也会变的长一些,需要下载、安装),接着再自动安装这个AIR应用。这个过程客户几乎察觉不到他安装了AIR。

Adobe AIR应用在线安装(配置方法) :

1.创建安装FLASH动画的背景图像

创建一个215px x 100px 图像,被用来作为背景。 默认的在线安装区域为 217px x 180px 。
2.配置SWF

参数:

  • 应用程序名称(appname):也就是你的AIR应用的名称。
  • 应用程序路径 (appurl):你的AIR应用程序的下载路径。 (比如:http://www.AIRia.cn/myAirApp.air)
  • AIR版本(airversion): AIR应用的版本。比如AIR1.1
  • 安装按钮的颜色(buttoncolor) :如果需要,可以试用十六进制定义一个按钮颜色。(默认是灰色)
  • 安装文字信息的颜色(messgagecolor) :如果需要,可以试用十六进制定义一个按钮颜色。(默认是黑色)
  • 背景图像地址(imageurl):背景图像地址。

    像这样:

用air模仿QQ的信息提示

// October 6th, 2008 // No Comments » // Flex积累

Icon Alerts
by Rich A Tretola on September 11, 2008 Avg Rating 4.7 (3)  |  Log in to rate post.

Tagged with icons , alerts , air , Flex

View Comments (0)

Problem
You would like to alert the user of something important that is occurring within the application by utilizing a flashing icon within the dock or system tray.

Solution
This is a custom solution that will utilize a filter to create a second icon that is colored in reverse of the original and a timer to swap the application icon from the original, to the reversed, and back.

Detailed description

The IconManager class below is a part of the everythingflexairlib.swc library which is hosted on Google Code. For more information, please visit http://blog.everythingflex.com/air-central/everythingflexair1swc/

The example below simply embeds a few pngs and sets their bitmapData into an Array named defaultSysDockIconBitmaps to be used as application icons. An instance of the IconManager is created and the defaultSysDockIconBitmaps are passed into the constructor. There is a second optional argument that allows you to pass in a second set of icons to be used as teh alternate icons that will sequence with the default set during an alert. If only the default icons are passed in, the second set is created in reverse color of the original by using a ColorMatrixFilter.

A basic example would then simply call the startAlert method on the IconManager. However, in this example, I have included a timer so that after you click on the startAlert method, you will have time to put focus onto a different window which will allow the bounce functionality to work if you are on a Mac. This example also passes in both optional arguments to the startAlert method. The first will be used on Windows machine’s as the toolTip for the system tray icon. The second defines the Notification type that will be used when the operating system is a Mac.

Although the IconManager class is defined below, I would recommend that you use the compiled swc file available at http://blog.everythingflex.com/air-central/everythingflexair1swc/

Usage of IconManager:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:WindowedApplication xmlns:mx=”http://www.adobe.com/2006/mxml”
width=”200″ height=”100″>

<mx:Script>
<![CDATA[
import com.everythingflex.air.managers.IconManager;

[Embed(source="assets/icons/AIRApp_16.png")]
private var Icon16:Class;
private var bitmap16:Bitmap = new Icon16();

[Embed(source="assets/icons/AIRApp_32.png")]
private var Icon32:Class;
private var bitmap32:Bitmap = new Icon32();

[Embed(source="assets/icons/AIRApp_48.png")]
private var Icon48:Class;
private var bitmap48:Bitmap = new Icon48();

[Embed(source="assets/icons/AIRApp_128.png")]
private var Icon128:Class;
private var bitmap128:Bitmap = new Icon128();

private var defaultSysDockIconBitmaps:Array = [bitmap16.bitmapData,
bitmap32.bitmapData,
bitmap48.bitmapData,
bitmap128.bitmapData];

private var i:IconManager = new IconManager(defaultSysDockIconBitmaps);

private var timer:Timer;

private function testAlert():void{
timer = new Timer(3000,1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE,timerComplete);
timer.start();
}

private function timerComplete(event:TimerEvent):void{
/**
* set toolTip to ‘ALERT! ALERT!’ (Windows Only)
* set NotificationType to CRITICAL (Mac Only)
*/
i.startAlert(‘ALERT! ALERT!’,NotificationType.CRITICAL)
}
]]>
</mx:Script>
<mx:Button click=”testAlert()” label=”Start Alert”
horizontalCenter=”0″ verticalCenter=”0″/>
</mx:WindowedApplication>

IconManager Class

/*
Copyright (c) 2008 EverythingFlex.com.
http://code.google.com/p/everythingflexairlib/

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package com.everythingflex.air.managers
{
import flash.desktop.NativeApplication;
import flash.desktop.NotificationType;
import flash.desktop.SystemTrayIcon;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.TimerEvent;
import flash.filters.ColorMatrixFilter;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.Timer;

public class IconManager
{
/**
*  @private
*  stores the Array of bitmaps tobe used as icons
*/
private var sysDockIconBitmaps:Array = new Array();
/**
*  @private
*  stores the Array of altered bitmaps tobe used as icons
*/
private var alteredSysDockIconBitmaps:Array = new Array();
/**
*  @private
*  stores the alertType, defaults to NotificationType.CRITICAL
*/
private var alertType:String = NotificationType.CRITICAL;
/**
*  @private
*  used as an indicator to determine which state of icon to display
*/
private var _count:int;
/**
*  @private
*  timer used to alternate between sysDockIcon and alteredSysDockIcon
*/
private static var ALERT_TIMER:Timer;
/**
*  Constructor.
*/
public function IconManager(sysDockIconBitmaps:Array,
alteredSysDockIconBitmaps:Array=null,
alertType:String=”critical”) {
this.sysDockIconBitmaps = sysDockIconBitmaps;
this.alteredSysDockIconBitmaps = alteredSysDockIconBitmaps;
this.alertType = alertType;
handleIcons();
}
/**
*  @private
*  called by constructor to initialize the icons sets
*/
private function handleIcons():void{
stopAlert();
if(NativeApplication.supportsDockIcon || NativeApplication.supportsSystemTrayIcon){
if(sysDockIconBitmaps.length > 0){
NativeApplication.nativeApplication.icon.bitmaps = sysDockIconBitmaps;
if(alteredSysDockIconBitmaps == null){
alteredSysDockIconBitmaps = new Array();
for (var i:int=0; i<sysDockIconBitmaps.length;i++){
alteredSysDockIconBitmaps.push(applyAlertFilter(sysDockIconBitmaps.clone(),i));
}
}
}
}
}
/**
*  @private
*  alters icon to reverse of original using a filter
*/
private function applyAlertFilter(bitmapData:BitmapData,i:int):BitmapData {
var matrix:Array = new Array();
matrix = matrix.concat([-1, 0, 0, 0, 255]);
matrix = matrix.concat([0, -1, 0, 0, 255]);
matrix = matrix.concat([0, 0, -1, 0, 255]);
matrix = matrix.concat([0, 0, 0, 1, 0]);
var r:Rectangle;
if(i == 0)r= new Rectangle(0,0,16,16);
if(i == 1)r= new Rectangle(0,0,32,32);
if(i == 2)r= new Rectangle(0,0,48,48);
if(i == 3)r= new Rectangle(0,0,128,128);
bitmapData.applyFilter(bitmapData,r,new Point(),new ColorMatrixFilter(matrix));
return new Bitmap(bitmapData).bitmapData;
}
/**
*  @public
*  starts an alert and shows toolTip message (Windows Only)
*/
public function startAlert(message:String=”Alert”):void{
IconManager.ALERT_TIMER = new Timer(500,0);
IconManager.ALERT_TIMER.addEventListener(TimerEvent.TIMER,changeIcon)
IconManager.ALERT_TIMER.start();
if(NativeApplication.supportsSystemTrayIcon){
SystemTrayIcon(NativeApplication.nativeApplication.icon).tooltip = message;
}
}
/**
*  @public
*  stops an alert
*/
public function stopAlert():void{
if(NativeApplication.supportsSystemTrayIcon){
SystemTrayIcon(NativeApplication.nativeApplication.icon).tooltip = “”;
}
try{
IconManager.ALERT_TIMER.stop();
} catch (e:Error){

}
}
/**
*  @private
*  timer handler, alters state of icon
*/
private function changeIcon(event:TimerEvent):void{
if(_count == 0){
if(sysDockIconBitmaps.length){
NativeApplication.nativeApplication.icon.bitmaps = sysDockIconBitmaps;
}
_count = 1;
} else {
if(alteredSysDockIconBitmaps.length){
NativeApplication.nativeApplication.icon.bitmaps = alteredSysDockIconBitmaps;
}
_count = 0;
}
}
}
}

AS3类:实现AIR应用的自动更新

// April 20th, 2008 // No Comments » // AS3知识积累, Flex积累

package Neo{
import flash.display.*;
import flash.filesystem.*;
import flash.desktop.Updater;
import flash.events.*;
import flash.net.*;
import flash.xml.*;
import flash.text.TextField;
import flash.utils.ByteArray;
import flash.events.IOErrorEvent;
public class AIRUpdater extends Sprite {
public var version:String;
public var updataURL:String;
private var updataRequest:URLRequest;
private var updataLoader=new URLLoader();
private var newVersion:String;
private var airURLString:String;
private var urlReq:URLRequest;
private var urlStream:URLStream;
private var fileData:ByteArray;
private var baseSprite:Sprite=new Sprite();
private var tipText:TextField=new TextField();
private var btYes:Sprite=new Sprite();
private var btYesText:TextField=new TextField();
private var btNo:Sprite=new Sprite();
private var btNoText:TextField=new TextField();
public function AIRUpdater():void {
baseSprite.graphics.beginFill(0×000000,0.5);
baseSprite.graphics.lineStyle(8,0×000000,0.1);
baseSprite.graphics.drawRoundRect(0,0,360,160,10);
baseSprite.graphics.endFill();
/*add base*/
tipText.width=300;
tipText.height=30;
tipText.x=tipText.y=30;
tipText.autoSize=”center”;
tipText.textColor=0xFFFFFF;
tipText.text=”You must update your AIR Application now,ok?”;
baseSprite.addChild(tipText);
/*add button*/
btYes.graphics.beginFill(0×000000,0.5);
btYes.graphics.lineStyle(1,0×000000,0.1);
btYes.graphics.drawRoundRect(0,0,36,20,10);
btYes.graphics.endFill();
btYesText.width=36;
btYesText.text=”Yes”;
btYesText.autoSize=”center”;
btYesText.textColor=0xFFFFFF;
btYes.addChild(btYesText);
btNo.graphics.beginFill(0×000000,0.5);
btNo.graphics.lineStyle(1,0×000000,0.1);
btNo.graphics.drawRoundRect(0,0,36,20,10);
btNo.graphics.endFill();
btNoText.width=36;
btNoText.text=”No”;
btNoText.autoSize=”center”;
btNoText.textColor=0xFFFFFF;
btNoText.selectable=btYesText.selectable=false;
btNo.addChild(btNoText);
btYes.x=100;
btYes.y=100;
btNo.x=210;
btNo.y=100;
btYes.buttonMode=btNo.buttonMode=true;
baseSprite.addChild(btYes);
baseSprite.addChild(btNo);
}
/*Function For Update Application*/
public function updateMyApp():void {
updataRequest=new URLRequest(updataURL);
updataLoader.load(updataRequest);
updataLoader.addEventListener(IOErrorEvent.IO_ERROR,errorHandler);
updataLoader.addEventListener(Event.COMPLETE,loaderCompleteHandler);
}
/*loaderCompleteHandler*/
function loaderCompleteHandler(event:Event):void {
try {
var result:XML=new XML(updataLoader.data);
if (version != result.version) {
newVersion=result.version;
airURLString=result.lastpublic;
trace(”马上更新到最新版吗?” + “有新的更新”);
addChild(baseSprite);
baseSprite.x=(stage.stageWidth-baseSprite.width)/2;
baseSprite.y=(stage.stageHeight-baseSprite.height)/2;
btYes.addEventListener(MouseEvent.CLICK,updateBtHandler);
btNo.addEventListener(MouseEvent.CLICK,removeBtHandler);
}
} catch (e:TypeError) {
trace(”Updata Application Error:Could not parse the XML file.”);
}
}
/*errorHandler*/
private function errorHandler(e:IOErrorEvent):void {
trace(”Updata Application Error:Had problem loading the XML File.”);
}
private function updateBtHandler(event:MouseEvent):void {
urlReq=new URLRequest(airURLString);
urlStream=new URLStream ;
fileData=new ByteArray ;
urlStream.addEventListener(Event.COMPLETE,loaded);
urlStream.load(urlReq);
}
private function removeBtHandler(event:MouseEvent):void {
removeChild(baseSprite);
}
private function loaded(event:Event):void {
urlStream.readBytes(fileData,0,urlStream.bytesAvailable);
writeAirFile();
}
private function writeAirFile():void {
var file:File=File.desktopDirectory.resolvePath(”lastPublish.air”);
var fileStream:FileStream=new FileStream ;
fileStream.addEventListener(Event.CLOSE,fileClosed);
fileStream.openAsync(file,FileMode.WRITE);
fileStream.writeBytes(fileData,0,fileData.length);
fileStream.close();
}
private function fileClosed(event:Event):void {
trace(”The AIR file is written.”);
var updater:Updater=new Updater ;
var airFile:File=File.desktopDirectory.resolvePath(”lastPublish.air”);
updater.update(airFile,newVersion);
}
}
}

调用示例:

import flash.display.*;
import flash.filesystem.*;
import flash.desktop.Updater;
import flash.events.*;
import flash.net.*;
import flash.xml.*;
import flash.utils.ByteArray;
import flash.events.IOErrorEvent;
import Neo.AIRUpdater;
var aupSample:AIRUpdater=new AIRUpdater();
aupSample.version=”alpha1″;
aupSample.updataURL=”http://localhost/testUpdate/version.xml”;
aupSample.updateMyApp();
addChild(aupSample);

用于判断版本的XML结构示意:

<?xml version=”1.0″ encoding=”utf-8″?>
<example>
<version>alpha2</version>
<lastpublic>http://localhost/testUpdate/main.air</lastpublic>
</example>

air窗口动画ico放到托盘显示

// February 28th, 2008 // No Comments » // AS3知识积累

 前述のとおり、ベータ2からシステムトレイにアイコンを表示できるようになりました。

これにより、システムトレイにアプリケーションの状態を示したり、システムトレイアイコンからメニューを開いてアプリケーションの操作を行ったりすることができるようになります(*注意:システムトレイアイコン表示については、Windowsのみの対応機能です。ほぼ同じような方法でMac OSXのDockIconへのアイコン表示も行えるようですが、今回は解説しません。ご了承ください)。

(more…)

air窗口在最前面显示

// February 28th, 2008 // No Comments » // 电脑知识

var wOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
var nw:NativeWindow = new NativeWindow(true, wOptions);
nw.width = 200;
nw.height = 100;
nw.title = “最前面に表示”;
nw.alwaysInFront = true;
nw.x = stage.window.x + nw.width + 20;

air3中的画图的基本用法

// January 4th, 2008 // No Comments » // AS3知识积累

<?xml version=”1.0″?>
<!– usingas/AddingChildrenAsUIComponents.mxml –>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>
<mx:Script><![CDATA[
import flash.display.Sprite;
import mx.core.UIComponent;

private var xLoc:int = 20;
private var yLoc:int = 20;
private var circleColor:Number = 0xFFCC00;

private function addChildToPanel():void {

var circle:Sprite = new Sprite();
circle.graphics.beginFill(circleColor);
circle.graphics.drawCircle(xLoc, yLoc, 15);

var c:UIComponent = new UIComponent();
c.addChild(circle);
panel1.addChild(c);

xLoc = xLoc + 5;
yLoc = yLoc + 1;
circleColor = circleColor + 20;
}
]]></mx:Script>

<mx:Panel id=”panel1″ height=”250″ width=”300″ verticalScrollPolicy=”off”/>

<mx:Button id=”myButton” label=”Click Me” click=”addChildToPanel();”/>

</mx:Application>

四国语言服装面料词汇啊,大家一定要顶啊,超级有用的东西啊!!

// December 14th, 2007 // No Comments » // 日语学习

一。日文服装面料词汇

1,纸样 パタ一ン /型纸

2,样品 サンプル

(more…)