Alert util

Preview:

DESCRIPTION

http://code.google.com/p/alertutil/Alert Manager in Adobe Flex

Citation preview

richmediaplus.utils.AlertUtilAlert Manager in Flex Project

Alvin / Aedis.Ju 朱文轩Blog: blog.richmediaplus.comEmail: aedisju@gmail.comCode: http://code.google.com/p/alertutil/

show(text:String = “”, 消息title:String = “”, 标题flags:uint = 0x4, 按钮parent:Sprite = null, 居中对象closeHandler:Function = null, 按钮处理函数iconClass:Class = null, 图标defaultButtonFlag:uint = 0x4 默认按钮):mx.controls.Alert

title

iconClass messageText

flags

defalutButton

closeHandler

parent

<1%Alert Code in Project :

天使魔鬼

客户

• 手动去找,总会有遗漏• 每次都需要重新编译• 修改的东西太多• …

烦!烦!烦!烦!

软件开发的三大愿望

1. 更高的 生产力2. 更少的 BUG3. 更容易 维护

生活中,软件开发对你来说有什么样的愿望

个人的愿望

个人的愿望

个人的愿望

个人的愿望

个人的愿望

• 代码能少则少,少做无用功。• 尽可能一个文件,不用到处去打开 / 关闭很多文件。• 外部文件 loading ,不用再编译。• …

对 Alert的期望

• 代码能少则少,少做无用功。• 尽可能一个文件,不用到处去打开 / 关闭很多文件。• 外部文件 loading ,不用再编译。• …

对 Alert的期望

Alert Manager/Controler

Manage mx.controls.Alert ?

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

MessageType

Question ?

Error X

Warning !

Information i

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

AlertType• OK• YesNo• YesCancel• YesNoCancel• …

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

show(text:String = “”, title:String = “”, flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4 ):Alert

show(text:String = “”, parent:Sprite = null, closeHandler:Function = null, ):Alert

show(text:String = “”, parent:Sprite = null, closeHandler:Function = null, ):Alert

show(text:String = “”, closeHandler:Function = null, parent:Sprite = null, ):Alert

AlertUti lshowOKMessage

showYesCancelMessage

showYesNoMessage

showYesNoCancelMessage

showOKMsg(text:String,closeHandler:Function = null,parent:Sprite = null,title:String = ""):Alert

showYesNoMsg(text:String,closeHandler:Function = null,parent:Sprite = null,defaultButtonFlag:uint = Alert.NO,title:String = ""):Alert

showYesNoCancelMsg(text:String,closeHandler:Function = null,parent:Sprite = null,defaultButtonFlag:uint = Alert.CANCEL,title:String = ""):Alert

show…Msg(…): Alert

show(text:String = “”, closeHandler:Function = null, parent:Sprite = null, ):Alert

这就是AlertUtil ?!

后面才是重点!

• register.idExist 用户名已经存在

• register.passwordRule 请输入 6-18 位字符的密码

• register.passwordRepeatRule 请重新输入一次相同的登录密码!

• register.regSuccess 注册成功

• register.addressConfirm 个性域名确认后无法修改,确定吗?

• common.undefinedError 不明的错误原因

Module.Action

MessageType

Question ?

Error X

Warning !

Information i

[MessageType].[Module].[Action]

• warning.register.idExist 用户名已经存在

• warning.register.passwordRule 请输入 6-18 位字符的密码

• warning.register.passwordRepeatRule 请重新输入一次相同的登录密码!

• info.register.regSuccess 注册成功

• question.register.addressConfirm 个性域名确认后无法修改,确定吗?

• error.common.undefinedError 不明的错误原因

MessageType.Module.Action

XML

<?xml version="1.0" encoding="UTF-8"?><message> <title>Project Title</title> <info> <register> <regSuccess> 用户注册成功。 </regSuccess> </register> </info> <warning> <register> <idExist> 用户名已经存在! </idExist> <passwordRule> 密码长度 6 ~ 16 个字符,字母区分大小写! </passwordRule> <passwordRepeatRule> 请重新输入一次相同的登录密码! </passwordRepeatRule> <oldNewPasswordDiff> 两次输入的密码不一致! </oldNewPasswordDiff> </register> </warning> <question> <register> <addressConfirm> 个性域名确认后无法修改,确认吗? </addressConfirm> </register> </question> <error> <login> <passwordWrong> 对不起,你的密码不正确! </passwordWrong> </login> <common> <undefinedError> 不明的错误原因! </undefinedError> </common> </error></message>

[MessageType].[Module].[Action]

MessageNode

showOKMsg(msgNode:String,closeHandler:Function = null,parent:Sprite = null,title:String = ""):Alert

AlertUtil

showYesNoMsg(msgNode:String,closeHandler:Function = null,parent:Sprite = null,defaultButtonFlag:uint = Alert.NO,title:String = ""):Alert

showYesNoCancelMsg(msgNode:String,closeHandler:Function = null,parent:Sprite = null,defaultButtonFlag:uint = Alert.CANCEL,title:String = ""):Alert

show…Msg(…): Alert

show(text:String = “”, closeHandler:Function = null, parent:Sprite = null, ):Alert

messageNode

AlertUtiltitle iconClass flags defaultButton

closeHandler parent

<warning> <register> <nameRequire> 注册名为必填字段,不能为空! </nameRequire> <passwordRequire> 密码为必填字段,不能为空! </passwordRequire> … <***Require>*** 为必填字段,不能为空! </***Require> … </register></warning><info> <search> <resultNone> 您搜索的关键字 *** ,返回结果为空。 </resultNone> </search></info>

<warning> <register> <nameRequire> 注册名为必填字段,不能为空! </nameRequire> <passwordRequire> 密码为必填字段,不能为空! </passwordRequire> <***Require>*** 为必填字段,不能为空! </***Require> </register></warning><info> <search> <resultNone> 您搜索的关键字 *** ,返回结果为空。 </resultNone> </search></info>

<warning> <register> <require>[0] 为必填字段,不必能为空! </require> </register></warning><info> <search> <resultNone> 您搜索的关键字 [0] ,返回结果为空。 </resultNone> </search></info>

showOKMsg(msgNode:String,

closeHandler:Function = null, paramArr:Array = null,parent:Sprite = null,title:String = ""):Alert

AlertUtil

showYesNoMsg(msgNode:String,

closeHandler:Function = null, paramArr:Array = null,parent:Sprite = null,defaultButtonFlag:uint = Alert.NO,title:String = ""): Alert

showYesNoCancelMsg(msgNode:String,

closeHandler:Function = null, paramArr:Array = null,parent:Sprite = null,defaultButtonFlag:uint = Alert.CANCEL,title:String = ""): Alert

show…Msg(…): Alert

messageNode

AlertUtiltitle iconClass flags defaultButton

closeHandler parent

parameters

AlertUtil• 直接提供了相应的 showOKMsg showYesNoMsg showYesNoCancelMsg• Message 信息集中化,方便管理,寻找,修改等操作。• Message 信息由 XML 配置,整个工程无需再编译发布新的 swf 版本。• 加入带参数的形式,合理改善因内容相同而对象不同的苦恼。

OpenSource in Google Project: http://code.google.com/p/alertutil/

Flex Project

ActionScript Project

Air Project

AlertUtil

创建适合你自己的 AlertUtil

Alvin / Aedis.Ju.air? air Jordan? air = atmosphere?no.no.no! air = ria = RIA = Rich Internet

Applications!

Thank you!