首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

flex右上脚提示

2012-09-21 
flex右下脚提示通过Alert显示提示信息实在太恶劣了,便想模仿QQ的提示,本想拿来主义,网上找个现成的,看了两

flex右下脚提示

通过Alert显示提示信息实在太恶劣了,便想模仿QQ的提示,本想拿来主义,网上找个现成的,看了两个都不太理想,还是自己动手吧。

首先是弹出的TitleWindow组件,用于显示信息,大家自己丰富吧:

<?xml version="1.0" encoding="utf-8"?><s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"   xmlns:s="library://ns.adobe.com/flex/spark"   xmlns:mx="library://ns.adobe.com/flex/mx"   width="200" height="80"   close="closeHandler(event)"   creationComplete="init()"><fx:Script><![CDATA[import mx.events.CloseEvent;import mx.events.FlexEvent;public var timeOut:int = 3000;[Bindable]public var msg:String;private function init():void{setTimeout(close,timeOut);}protected function closeHandler(event:CloseEvent):void{this.close();}private function close():void{BottomTip.removePopUp(this);}public function location(sw:int,sh:int):void{this.x = sw - this.width;this.y = sh - this.height;}]]></fx:Script><fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处 --></fx:Declarations><s:Label text="{msg}"/></s:TitleWindow>

?接下来是外部使用的接口类

package {import flash.display.DisplayObject;import flash.display.Stage;import mx.core.FlexGlobals;import mx.core.mx_internal;import mx.effects.Move;import mx.events.TweenEvent;import mx.managers.PopUpManager;public class BottomTip{private var sWidth:int;private var sHeight:int;private var parent:DisplayObject;public var title:String;public var msg:String;public var type:String;public function BottomTip(parent:DisplayObject){this.parent = parent;var stage:Stage = FlexGlobals.topLevelApplication.stage;sWidth = stage.stageWidth;sHeight = stage.stageHeight;}public function showMsg(msg:String,title:String="操作提示",type:String=""):void{var window:BottomWindow = new BottomWindow();window.title = title;window.msg = msg;window.location(sWidth,sHeight);var move:Move = new Move(window);move.duration=500;move.yFrom = sHeight;move.yTo = window.y;PopUpManager.addPopUp(window,parent);move.play();}internal static function removePopUp(window:BottomWindow):void{var move:Move = new Move(window);move.duration = 500;move.yFrom = window.y;move.yTo = FlexGlobals.topLevelApplication.stage.stageHeight;move.addEventListener(TweenEvent.TWEEN_END,function():void{PopUpManager.removePopUp(window);});move.play();}}}

?使用示例

new BottomTip(this).showMsg("让我们来测试测试吧,哈哈哈");
?

?

?

热点排行