弹出TitleWindow的缓冲特效

1、实现左进又出,下面是个例子

主应用程序:

<?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"
      xmlns:ns1="Components.*"
      minWidth="955"
      minHeight="600">
 <fx:Declarations>
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
 </fx:Declarations>
 <fx:Script>
  <![CDATA[
   import mx.controls.Alert;
   import mx.managers.PopUpManager;
   import Components.LoginTitleWindow;
   private function loginWindow():void
   {
    var loginWindow:LoginTitleWindow=LoginTitleWindow(
     PopUpManager.createPopUp(this, LoginTitleWindow, false));
   }
  ]]>
 </fx:Script>
 <mx:Button id="showLoginWindow"
      x="36"
      y="93"
      label="show loginWindow"
      click="loginWindow()"/> 
</s:Application>

TitleWindow组件:
LoginTitleWindow.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute" width="308" height="204"
    title="登陆窗口" fontSize="12"
    showCloseButton="true" horizontalAlign="left"
    textAlign="center"
    close="titleWindow_close()"
    creationComplete="init()"
    alpha="0.75"
    borderAlpha="0.75"
    >
 <mx:Script>
  <![CDATA[
   
   import mx.managers.PopUpManager;
   [Bindable]
   private var comboxType:Array = ["学生","老师","管理员"];
   private var easing:Number = 0.2;
   private var targetX:Number = 0;
   private var targetY:Number = 0;
   private var flag:Boolean = false;
   private var vx:Number = 0;
   private var vy:Number = 0;
   //初始化登陆窗口
   private function init():void{
    //this.isPopUp = false;
    this.y = (this.parent.stage.stageHeight - this.height)/2;
    flag = false;
    targetX = (this.parent.stage.stageWidth - this.width) / 2;
    this.addEventListener(Event.ENTER_FRAME,onEnterFrame);
   }
   private function onEnterFrame(event:Event):void{
    if(flag){
     vx = (targetX - this.x) * easing;
     this.x += vx;
     if(targetX - this.x < 5){
      this.removeEventListener(Event.ENTER_FRAME,onEnterFrame);
      PopUpManager.removePopUp(this);
      trace("false");
     }
    }else{
     vx = (targetX - this.x) * easing;
     this.x += vx;
     if(targetX - this.x < 5){
      this.removeEventListener(Event.ENTER_FRAME,onEnterFrame);
      trace("true");
     }
    } 
   }
   
   //点击叉叉关闭登陆窗口
   private function titleWindow_close():void{
    flag = true;
    targetX = this.parent.stage.stageWidth;
    this.addEventListener(Event.ENTER_FRAME,onEnterFrame);
   }
   
   //点击取消关闭登陆窗口
   private function loginCancle_event():void{
    this.titleWindow_close();
   }
   
   //点击登陆进行判断
   private function loginSure_event():void{
    trace(loginId.text);
    trace(loginPassword.text);
    trace(loginType.text);
   }
  ]]>
 </mx:Script>
 <mx:Form x="10" width="268">
  <mx:FormItem label="账号 :">
   <mx:TextInput id="loginId" textAlign="left"/>
  </mx:FormItem>
  <mx:FormItem label="密码 :">
   <mx:TextInput id="loginPassword" displayAsPassword="true" textAlign="left"/>
  </mx:FormItem>
  <mx:FormItem label="类型 :" fontSize="12">
   <mx:ComboBox id="loginType" dataProvider="{comboxType}"></mx:ComboBox>
  </mx:FormItem> 
 </mx:Form>
 <mx:Button id="loginCancle" x="201" y="130" label="取消" click="loginCancle_event()"/>
 <mx:Button id="loginSure" x="124" y="130" label="登陆" click="loginSure_event()"/>
</mx:TitleWindow>


你可能感兴趣的:(弹出TitleWindow的缓冲特效)