Flex4 弹出窗口滑入滑出

先看示例:
[flash=400,300]https://dl.dropbox.com/u/38216791/flex/samples/moveEffect/samples.swf[/flash]

代码SimpleMessageBox:


<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer 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" backgroundColor="0xFF0000"
visible="false"
showEffect="{seq}"
initialize="bordercontainer1_initializeHandler(event)"
creationComplete="bordercontainer1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.EffectEvent;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;

protected function bordercontainer1_creationCompleteHandler(event:FlexEvent):void
{
var w:Number = msgLabel.measuredWidth + 5;
moveIn.xBy = -w;
moveOut.xBy = w;

this.height = msgLabel.measuredHeight + 5;

this.visible = true;
}

[Bindable]
protected static var instance:SimpleMessageBox;

private static var _message:String;

public static function show(message:String, parent:DisplayObject):void
{
if(instance != null)
return;

instance = new SimpleMessageBox();
_message = message;

instance.x = parent.x + parent.width;
instance.y = 10;

PopUpManager.addPopUp(instance, parent);
}

protected function seq_effectEndHandler(event:EffectEvent):void
{
PopUpManager.removePopUp(instance);
instance = null;
}

protected function bordercontainer1_initializeHandler(event:FlexEvent):void
{
msgLabel.text = _message;
}

]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<s:Sequence id="seq" effectEnd="seq_effectEndHandler(event)" target="{instance}">
<s:Move id="moveIn" duration="1000"/>
<!--用startDelay指定滑出前的暂停时间-->
<s:Move id="moveOut" duration="1000" startDelay="3000"/>
</s:Sequence>
</fx:Declarations>

<s:Label id="msgLabel" width="100%" maxDisplayedLines="2" verticalAlign="middle"/>
</s:BorderContainer>


application关键代码:


<fx:Script>
<![CDATA[
import controls.SimpleMessageBox;

import mx.events.EffectEvent;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;

import spark.components.BorderContainer;
import spark.components.Label;

protected function showMessageBox():void
{
SimpleMessageBox.show(msgInput.text, this);
}

protected function msgInput_creationCompleteHandler(event:FlexEvent):void
{
msgInput.setFocus();
}

]]>
</fx:Script>

<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>

<s:TextInput id="msgInput" x="10" y="10"
creationComplete="msgInput_creationCompleteHandler(event)" enter="showMessageBox()"
text="注意啦,回车也能弹出来啦"/>
<s:Button x="10" y="50" label="show" click="showMessageBox()"/>
<s:Button x="10" y="80" label="clear input" click="msgInput.text='';"/>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值