Flex 自带的Alert带给用户的体验并不好,对于一些简单的提示来说,这个小题大作了。

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

<fx:Script>
<![CDATA[
protected function popupBtn_clickHandler(event:MouseEvent):void
{
AlertUtil.show(this,"hello,world","保存成功");
}
]]>
</fx:Script>

<fx:Declarations>

</fx:Declarations>
<s:Button id="popupBtn" x="562" y="273" label="弹窗" click="popupBtn_clickHandler(event)"/>
</s:Application>

<p>/**
* hisuper_hjx,上午10:49:24
*/
package
{
import flash.events.TimerEvent;
import flash.utils.Timer;

import mx.core.FlexGlobals;
import mx.core.IFlexDisplayObject;
import mx.core.UIComponent;
import mx.events.EffectEvent;
import mx.managers.PopUpManager;

import spark.components.Application;
import spark.effects.Fade;</p><p> public class AlertUtil
{
public function AlertUtil()
{

}

//显示内容
public static function show(title:String="",content:String="",time:Number=1000):void{
var application:Application=FlexGlobals.topLevelApplication as Application;
var alertLabel:AlertLabel=new AlertLabel();//弹窗组件;
var timer:Timer=new Timer(time);//计时器
var fade:Fade=new Fade();//渐变
fade.alphaFrom=0;
fade.alphaTo=1;
fade.target=alertLabel;
fade.duration=300;

alertLabel.text=content;
PopUpManager.addPopUp(alertLabel,application);//弹窗;
PopUpManager.centerPopUp(alertLabel);
fade.play();

timer.addEventListener(TimerEvent.TIMER,function timerEventHandler(event:TimerEvent):void{
fade.alphaFrom=1;
fade.alphaTo=0;
fade.play();
fade.addEventListener(EffectEvent.EFFECT_END,function fadeEndHandler(event:EffectEvent):void{
PopUpManager.removePopUp(alertLabel);
});
});

timer.start();
}

}
}</p>

/**
* hisuper_hjx,上午11:05:47
*/
package
{
import skins.AlertLabelSkin;

import spark.components.supportClasses.SkinnableComponent;

public class AlertLabel extends SkinnableComponent
{

private var _text:String

public function AlertLabel()
{
super();
setStyle("skinClass",AlertLabelSkin);
}

[Bindable]
public function get text():String
{
return _text;
}

public function set text(value:String):void
{
_text = value;
}

}
}

<?xml version="1.0" encoding="utf-8"?>
<s:Skin 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="160" height="100">
<!-- host component -->
<fx:Metadata>
[HostComponent("AlertLabel")]
</fx:Metadata>
<s:Group left="0" right="0" top="0" bottom="0">
<s:Group left="0" right="0" top="0" bottom="0">
<s:Rect left="0" right="0" top="0" bottom="0" radiusX="20" radiusY="20">
<s:fill>
<s:SolidColor color="0"/>
</s:fill>
</s:Rect>
</s:Group>

<s:Label id="label" color="0xffffff" fontSize="18" horizontalCenter="0"
text="{hostComponent.text}" verticalCenter="0"
fontFamily="微软雅黑"/>
</s:Group>
</s:Skin>

Flex友好提示、警告的更多相关文章

  1. Altium Designer 出现错误提示(警告)adding items to hidden net GND/VCC

    一般出现这个提示,不是错误. 可以取消net 网格标号 这样就不会报这个警告了. 还可以设置规则,不让它报告. 点击确定,但是再次打开工程时有得警告这个错误了.我想,还是取消NET标注.

  2. tomcat提示警告: An attempt was made to authenticate the locked user"tomcat"

    启动tomcat7之后,运行正常,但是运行一段时间就会提示以下警告: 十二月 04, 2013 5:10:15 下午 org.apache.catalina.realm.LockOutRealm au ...

  3. iOS-硬件声音 ,振动,提示警告

    为了引起用户注意发出警告的时候,常常伴随有提示音震动等.系统声音服务提供了一个接口,用于播放不超过30秒的声音文件,他支持的格式有CAF,AIF,WAV. iOS使用该API支持3种不同的通知: 声音 ...

  4. ME21N增强提示警告消息

    在ME21N增强中,可以使用message的方法提示错误的消息,但警告消息使用message则提示不了,需要使用系统宏mmpur_message 提示. data:begin of lw_equp, ...

  5. Qt之实现网络下发配置的半透明友好提示界面

    一.说明 在使用Qt开发的网管客户端程序中,网管客户端主要负责显示设备信息以及对设备下发配置信息等,如配置设备名字.更新设备程序等:由于在网管客户端程序的操作要先经过服务器处理,再由服务器将该命令转发 ...

  6. 重写alert方法完成类似gmail的友好提示

    当在网页中调用aelrt()方法的时候,系统会自动显示友好的提示方式 . 下面是css样式控制代码: /*----------------------------------------------- ...

  7. vue-router 实现无效路由(404)的友好提示

    最近在做一个基于vue-router的SPA,想对无效路由(404)页面做下统一处理.这次我真的没有在官方文档找到具体的说明[捂脸]所以本文仅是我DIY的一个思路,求轻虐=_= 在我的理解中,vue- ...

  8. WPF Adorner+附加属性 实现控件友好提示

    标题太空泛,直接上图 无论是在验证啊,还是提示方面等一些右上角的角标之类的效果,我们会怎么做? 这里介绍一种稍微简单一些的方法,利用附加属性和Adorner来完成. 例如WPF自带的控件上要加这样的效 ...

  9. js友好提示是否继续,post提交

    <script type="text/javascript"> function delcheck(qId,typeid) { if (!confirm('确定删除吗? ...

随机推荐

  1. busybox filesystem matrix-gui-2.0 undefined function json_encode()

    /******************************************************************************** * matrix-gui-2.0 u ...

  2. java/python中获取当前系统时间,并与字符串相互转换格式,或者转化成秒数,天数等整数

    java转换成秒数 Date类有一个getTime()可以换回秒数,例如: public class DateToSecond { public static void main(String[] a ...

  3. 【转】Android Studio -修改LogCat的颜色*美爆了*

    原文网址:http://www.2cto.com/kf/201505/400357.html 一. 先看效果 二.设置 File->Settings 或Ctrl + Alt +S 找到 Edit ...

  4. 多线程监控文件夹,FlieSystemWatcher,并使用共享函数

    发表于: 2011-01-06 09:55:47   C# code   ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2 ...

  5. 22、TTS技术

    Android对TTS技术的支持 Android 1.6开始支持TTS(Text To Speech)技术,通过该技术可以将文本转换成语音. TTS技术的核心是android.speech.tts.T ...

  6. 使用buildbot实现持续集成(转载)

    转载自:http://www.oschina.net/p/buildbot 使用 Buildot 实现持续集成 使用基于 Python 的工具实现持续集成的理论与实践 牛仔式编码的日子在大多数组织中早 ...

  7. UINavigationController 操作记录

    //设置字体大小 颜色 { UIColor *color = [UIColor brownColor]; UIFont * font = [UIFont systemFontOfSize:20]; N ...

  8. 仿酷狗音乐播放器开发日志十一——CTreeNodeUI的bug修复

    由于做播放列表控件,我的CMusicLength控件继承了CTreeVieWUI控件,在向分组控件中添加播放项目时,发现代码无法正常工作,调用CTreeNodeUI控件的Add方法后无反应,导致我的播 ...

  9. <转>配置DNS辅助服务器:DNS系列之四

    配置DNS辅助服务器   在前面的博文中,我们介绍了如何在DNS服务器中创建常用的DNS记录,本文中我们要为大家介绍如何配置DNS的辅助服务器,同时也要介绍一下和辅助区域类似的存根区域. DNS辅助服 ...

  10. C/C++:类模板

    类模板就是为类声明一种模板,使得类中的某些数据成员,或某些成员函数的参数,又或者是某些成员函数的返回值可以取任意的数据类型,包括基本数据类型和自定义数据类型. 类模板的声明形式如下: template ...