FlashDevelop 復習(3)
如何下指令關閉AIR程式。
package com.lovecocoa
{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.media.StageWebView;
import flash.geom.Rectangle;
import flash.events.Event;
import flash.display.Graphics;
import flash.events.MouseEvent;
import flash.desktop.NativeApplication;
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowType;
public class Main extends Sprite
{
public function Main():void
{
//新增一個按鈕
this.testButton();
}
protected function testButton():void
{
var button:Sprite;
//Create a new instance of a Sprite to act as the button graphic.
button = new Sprite();
//Set the color of the button graphic
button.graphics.beginFill(0xFFCC00);
//Set the X,Y, Width, and Height of the button graphic
button.graphics.drawRect(0, 0, 200, 200);
//Apply the fill
button.graphics.endFill();
//Add useHandCursor, buttonMode, and mouseChildren if required
button.useHandCursor = true;
button.buttonMode = true;
button.mouseChildren = false;
button.addEventListener(MouseEvent.CLICK, buttonClickHandler);
//button.addEventListener(MouseEvent.ROLL_OVER, buttonRollOverHandler);
//button.addEventListener(MouseEvent.ROLL_OUT, buttonRollOutHandler);
//Add Button Sprite to stage
this.addChild(button);
}
private function buttonClickHandler(event:MouseEvent):void
{
//trace("Button clicked!");
//當按下之後就關閉整個視窗
NativeApplication.nativeApplication.exit();
}
private function buttonRollOverHandler(event:MouseEvent):void
{
trace("Button roll over!");
}
private function buttonRollOutHandler(event:MouseEvent):void
{
trace("Button roll out!");
}
}
}
package com.lovecocoa
{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.media.StageWebView;
import flash.geom.Rectangle;
import flash.events.Event;
import flash.display.Graphics;
import flash.events.MouseEvent;
import flash.desktop.NativeApplication;
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowType;
public class Main extends Sprite
{
public function Main():void
{
//新增一個按鈕
this.testButton();
}
protected function testButton():void
{
var button:Sprite;
//Create a new instance of a Sprite to act as the button graphic.
button = new Sprite();
//Set the color of the button graphic
button.graphics.beginFill(0xFFCC00);
//Set the X,Y, Width, and Height of the button graphic
button.graphics.drawRect(0, 0, 200, 200);
//Apply the fill
button.graphics.endFill();
//Add useHandCursor, buttonMode, and mouseChildren if required
button.useHandCursor = true;
button.buttonMode = true;
button.mouseChildren = false;
button.addEventListener(MouseEvent.CLICK, buttonClickHandler);
//button.addEventListener(MouseEvent.ROLL_OVER, buttonRollOverHandler);
//button.addEventListener(MouseEvent.ROLL_OUT, buttonRollOutHandler);
//Add Button Sprite to stage
this.addChild(button);
}
private function buttonClickHandler(event:MouseEvent):void
{
//trace("Button clicked!");
//當按下之後就關閉整個視窗
NativeApplication.nativeApplication.exit();
}
private function buttonRollOverHandler(event:MouseEvent):void
{
trace("Button roll over!");
}
private function buttonRollOutHandler(event:MouseEvent):void
{
trace("Button roll out!");
}
}
}
留言
張貼留言