• Adobe Flex迷你教程 — Super easy实现Mac系统下滑式Alert窗口


    这段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>
  • 相关阅读:
    点图换说明文字
    酷酷的图片预览带加载效果
    阿里巴巴右侧6滑块VS雅虎右侧6滑块VS自定义6滑块
    绝对经典的滑轮新闻显示(javascript+css)
    一个城市、日历选择功能
    比较两个日期大小
    我对委托/事件的理解
    今天写信息采集小程序时实现程序中同时只允许5个线程运行
    Web页面接受客户端POST数据,并且返回数据
    项目中用到的一个树控件[经过修改]
  • 原文地址:https://www.cnblogs.com/yangpigao/p/2936751.html
Copyright © 2020-2023  润新知