浏览 2886 次
锁定老帖子 主题:flex右下脚提示
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-08-10
通过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("让我们来测试测试吧,哈哈哈");
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2011-08-15
http://www.smithfox.com/?e=173
|
|
返回顶楼 | |