Adobe Flex迷你教程 — Super easy实现Mac系统下滑式Alert窗口
2013-02-28 13:35
429 查看
这段code是参考kevin先生的,我简单做了修改。
下面为主应用程序的代码
package comalert { import flash.display.DisplayObject; import flash.display.Sprite; import mx.controls.Alert; import mx.core.Application; import mx.core.FlexGlobals; import mx.effects.Move; import mx.effects.Parallel; import mx.effects.WipeDown; import mx.effects.WipeUp; import mx.managers.PopUpManager; public class KAlert { public function KAlert() { } public static function show(text:String,modal:Boolean = false):void{ var alert:Alert = new Alert(); //setAppleStyle(alert); setOpenEffect(alert); alert.text = text; var parent:Sprite = Sprite(FlexGlobals.topLevelApplication); alert.x = FlexGlobals.topLevelApplication.width/2-100; PopUpManager.addPopUp(alert, parent, modal); alert.setActualSize(alert.getExplicitOrMeasuredWidth(), alert.getExplicitOrMeasuredHeight()); } private static function setOpenEffect(alert:Alert):void{ var wipeUp:WipeUp = new WipeUp(); //Wipe效果,方向向上 var move:Move = new Move(); //移定效果 var parallel:Parallel = new Parallel(); //加入其中的效果会被并发执行 parallel.addChild(move); parallel.addChild(wipeUp); //设置弹出框在正中央 move.xFrom = FlexGlobals.topLevelApplication.width/2-100; move.xTo = FlexGlobals.topLevelApplication.width/2-100; //弹出时从-100移动到100,同时wipeUp move.yFrom = 100; move.yTo = 200; //动画执行时间为300毫秒 wipeUp.duration = 1000; move.duration=1000; //在当前控件被加入舞台时执行 alert.setStyle("addedEffect",parallel) } } }
下面为主应用程序的代码
<?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[ import comalert.KAlert; protected function button1_clickHandler(event:MouseEvent):void { // TODO Auto-generated method stub KAlert.show("Test Slide Effect"); } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <s:Button id="SlideAlert" click="button1_clickHandler(event)"/> </s:Application>
相关文章推荐
- Flex:实现Mac系统下滑式Alert窗口
- Adobe Flex迷你教程 — ActionScript实现二维向量运算
- Adobe Flex迷你教程 — 实现类似新浪微博评论消息容器
- C#实现窗口最小化到系统托盘
- Win7系统下利用U盘安装Ubuntu_12.04实现双系统教程
- 虚拟机装MAC系统,实现真机调式
- windows8.1使用虚拟机安装MAC系统注意事项及教程
- java swing mysql实现的ktv点歌系统项目源码附带视频教程
- mac系统命令行窗口输入javac命令,输出中文乱码得问题
- 在Mac系统下发布Qt程序详细教程
- Win7系统下利用U盘安装Ubuntu_12.04实现双系统教程
- java开发系统内核:依靠多任务实现多窗口
- iPhone/Mac Objective-C内存管理教程和原理剖析(四)系统自动创建新的autorelease pool
- 用xmlhttp和Java session监听改善站内消息系统,实现站内消息弹出窗口
- js提示框替代系统alert,自动关闭alert对话框的实现方法
- 苹果MAC系统多分区方案实现
- iPhone/Mac Objective-C内存管理教程和原理剖析(四)系统自动创建新的autorelease pool
- 【转】windows环境下安装win8.1+Mac OS X 10.10双系统教程
- CentOS实现回收站机制_Linux教程_Linux公社-Linux系统门户网站
- 简单制作 OS X Yosemite 10.10 正式版U盘USB启动安装盘方法教程 (全新安装 Mac 系统)