演示效果
Alert类
- /**
- * @link http://www.klstudio.com
- * @author Kinglong
- * @usage flash player 7
- * @version 0.1
- */
- import mx.transitions.*;
- import mx.transitions.easing.*;
- class as2.game.Alert extends MovieClip{
- private static var __id:String = "alert_mc";
- private static var __alert:MovieClip;
- private var __handler:Function;
- private var __top_mc:MovieClip;
- private var __box_mc:MovieClip;
- private var __bottom_mc:MovieClip;
- private var __close_btn:Button;
- private var __ok_btn:Button;
- private var __tween:Tween;
- private var __message_txt:TextField;
- private var __hit_btn:Button;
- private function Alert() {
- _xscale = _yscale = 100;
- __hit_btn.useHandCursor = false;
- __hit_btn._alpha = 80;
- __ok_btn.onRelease = __close_btn.onRelease = _closeHandler;
- __message_txt.autoSize = "Left";
- _update();
- _showTween();
- }
- private function _setMessage(message:String):Void {
- __message_txt.text = message;
- _update();
- }
- private function _setHandler(handler:Function):Void {
- __handler = handler;
- }
- private function _move(x:Number, y:Number):Void {
- _x = Math.floor(x);
- _y = Math.floor(y);
- __hit_btn._width = Stage.width;
- __hit_btn._height = Stage.height;
- __hit_btn._x = -_x;
- __hit_btn._y = -_y;
- }
- private function _update():Void {
- __hit_btn._width = 1;
- __hit_btn._height = 1;
- __hit_btn._x = 0;
- __hit_btn._y = 0;
- __box_mc._height = __message_txt._height + 15;
- __bottom_mc._y = __box_mc._y + __box_mc._height;
- __ok_btn._y = __bottom_mc._y - 15;
- _move((Stage.width - _width)/2,(Stage.height - _height)/2);
- }
- private function _close():Void {
- if (__handler != null) {
- __handler.apply(null, []);
- }
- this.removeMovieClip();
- delete __alert;
- }
- private function _closeHandler():Void {
- _parent._closeTween();
- }
- private function _showTween():Void {
- __tween = new Tween(this, "_alpha", Strong.easeOut, 50, 100, 1, true);
- __tween["state"] = "show";
- __tween.onMotionFinished = _tweenHandler;
- }
- private function _closeTween():Void {
- __tween = new Tween(this, "_alpha", Strong.easeOut, 100, 0, 0.2, true);
- __tween["state"] = "close";
- __ok_btn.enabled = __close_btn.enabled = false;
- __message_txt._visible = false;
- __tween.onMotionFinished = _tweenHandler;
- }
- private function _tweenHandler():Void {
- switch(this["state"]){
- case "close":
- __alert._close();
- break;
- case "show":
- break;
- }
- }
- public static function show(message:String, handler:Function):Void {
- if (__alert == null) {
- __alert = _root.attachMovie(__id, "alert", _root.getNextHighestDepth());
- }
- __alert._setMessage(message);
- __alert._setHandler(handler);
- }
- private static function close():Void {
- if (__alert != null) {
- __alert._close();
- }
- }
- }
Confirm类
- /**
- * @link http://www.klstudio.com
- * @author Kinglong
- * @usage flash player 7
- * @version 0.1
- */
- import mx.transitions.*;
- import mx.transitions.easing.*;
- class as2.game.Confirm extends MovieClip{
- private static var __id:String = "confirm_mc";
- private static var __confirm:MovieClip;
- private var __handler:Function;
- private var __top_mc:MovieClip;
- private var __box_mc:MovieClip;
- private var __bottom_mc:MovieClip;
- private var __close_btn:Button;
- private var __ok_btn:Button;
- private var __cancel_btn:Button;
- private var __tween:Tween;
- private var __message_txt:TextField;
- private var __hit_btn:Button;
- private var __selected:Boolean;
- private function Confirm() {
- _xscale = _yscale = 100;
- __hit_btn._alpha = 80;
- __hit_btn.useHandCursor = false;
- __ok_btn.onRelease = _okHandler;
- __cancel_btn.onRelease = __close_btn.onRelease = _closeHandler;
- __message_txt.autoSize = "Left";
- _update();
- _showTween();
- }
- private function _setMessage(message:String):Void {
- __message_txt.text = message;
- _update();
- }
- private function _setHandler(handler:Function):Void {
- __handler = handler;
- }
- private function _move(x:Number, y:Number):Void {
- _x = Math.floor(x);
- _y = Math.floor(y);
- __hit_btn._width = Stage.width;
- __hit_btn._height = Stage.height;
- __hit_btn._x = -_x;
- __hit_btn._y = -_y;
- }
- private function _update():Void {
- __hit_btn._width = 1;
- __hit_btn._height = 1;
- __hit_btn._x = 0;
- __hit_btn._y = 0;
- __box_mc._height = __message_txt._height + 15;
- __bottom_mc._y = __box_mc._y + __box_mc._height;
- __cancel_btn._y = __ok_btn._y = __bottom_mc._y - 15;
- _move((Stage.width - _width)/2,(Stage.height - _height)/2);
- }
- private function _close():Void {
- if (__handler != null) {
- __handler.apply(null, [__selected]);
- }
- this.removeMovieClip();
- delete __confirm;
- }
- private function _okHandler():Void {
- _parent.__selected = true;
- _parent._closeTween();
- }
- private function _closeHandler():Void {
- _parent.__selected = false;
- _parent._closeTween();
- }
- private function _showTween():Void {
- __tween = new Tween(this, "_alpha", Strong.easeOut, 50, 100, 1, true);
- __tween["state"] = "show";
- __tween.onMotionFinished = _tweenHandler;
- }
- private function _closeTween():Void {
- __tween = new Tween(this, "_alpha", Strong.easeOut, 100, 0, 0.2, true);
- __tween["state"] = "close";
- __cancel_btn.enabled = __ok_btn.enabled = __close_btn.enabled = false;
- __message_txt._visible = false;
- __tween.onMotionFinished = _tweenHandler;
- }
- private function _tweenHandler():Void {
- switch(this["state"]){
- case "close":
- __confirm._close();
- break;
- case "show":
- break;
- }
- }
- public static function show(message:String, handler:Function):Void {
- if (__confirm == null) {
- __confirm = _root.attachMovie(__id, "confirm", _root.getNextHighestDepth());
- }
- __confirm._setMessage(message);
- __confirm._setHandler(handler);
- }
- private static function close():Void {
- if (__confirm != null) {
- __confirm._close();
- }
- }
- }
相关文件打包下载:http://www.klstudio.com/demo/test/win.rar (fla源文件需要用Flash CS3打开)





admin#flashas.net (#为@) 联系QQ:
:40777822