DFdou's Blog Life is short,Be yourself.

2704/090

AIR-Application minimize,drag and exit

I installed Flash CS4 today,found that it's easy to create AIR Application in CS4!! Between Flex and Flash,I like Flash IDE best!
Because if u use Flex IDE,u should know MXML and AS3,but if use Flash,only AS3 is good enough.OK,it's the time to goto the subject.
When we create an AIR Application,we may want to minimize it,drag it and exit it by some MC(movieclip) or Button,then how can we do it?
Core Class Main.as here:

package {
	import flash.desktop.NativeApplication;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;

	public class Main extends MovieClip {
		public var closeBt:MovieClip;
		public var minBt:MovieClip;
		public var recordBox:MovieClip;

		public function Main():void {
			btn_close.addEventListener(MouseEvent.CLICK, closeApp);
			btn_min.addEventListener(MouseEvent.CLICK, minApp);
			btn_drag.addEventListener(MouseEvent.MOUSE_DOWN, dragApp);
		}
		//drag Application with btn_drag
		private function dragApp(_evt:MouseEvent):void {
			stage.nativeWindow.startMove();
		}
		//close Application
		private function closeApp(_evt:MouseEvent):void {
			NativeApplication.nativeApplication.exit();
		}
		//minimize Application
		private function minApp(_evt:MouseEvent):void {
			stage.nativeWindow.minimize();
		}
	}
}

Then,import this Main.as in your Application,everything is OK~It's so easy work,isn't it?

Some Related Posts

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

:zhuang :xizao :wuwu :wenhao :wc :touxiang :shuaya :shuajian :shengtian :paopao :no :meinv :maonv :loveu :leilei :kua :jrjr :dahan :chi :chaocai :byebye


CommentLuv Enabled

No trackbacks yet.