2013-07-25 129 views
0

enter image description here从弹出窗口弹出的视图之间的导航

我工作的Flex应用程序。我遇到了以下问题:事实上,在第一页中显示的认证弹出窗口仅在用户存在于数据库中时才会关闭。这部分工作正常,但我想在弹出窗口中创建一个链接,帮助用户恢复其帐户。我的问题,我不知道如何导航到恢复电子邮件的页面,我使用状态,但它没有工作,请你能帮助我。这是鉴别弹出

<?xml version="1.0" encoding="utf-8"?> 
<s:TitleWindow 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:services="services.*" 
       x="400" y="400" width="400" height="196" cornerRadius="10" 
       creationComplete="doInit();" fontSize="12" title="Authentication" xmlns:local="*"> 
    <fx:Declarations> 
     <s:CallResponder id="authenticateUserResult"/> 
     <services:UserServiceImpl id="userServiceImpl" 
            fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" 
            showBusyCursor="true"> 
      <services:channelSet> 
       <s:ChannelSet> 
        <s:AMFChannel uri="http://localhost:8080/SmartSupport/messagebroker/amf"/> 
       </s:ChannelSet> 
      </services:channelSet> 
     </services:UserServiceImpl> 
     <s:CallResponder id="setMyStringResult"/> 
     <services:MySessionHandler id="mySessionHandler" 
            fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" 
            showBusyCursor="true"> 
      <services:channelSet> 
       <s:ChannelSet> 
        <s:AMFChannel uri="http://localhost:8080/SmartSupport/messagebroker/amf"/> 
       </s:ChannelSet> 
      </services:channelSet> 
     </services:MySessionHandler> 

      <s:CallResponder id="authenticationResp"/> 

     <!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). --> 
    </fx:Declarations> 


    <fx:Script> 
     <![CDATA[ 
      import com.roamsmart.acl.CurrentUser; 

      import mx.controls.Alert; 
      import mx.core.Application; 
      import mx.core.FlexGlobals; 
      import mx.events.CloseEvent; 
      import mx.managers.PopUpManager; 
      import mx.rpc.events.ResultEvent; 

      import valueObjects.UserEntity; 

      [Bindable] 
      public var currentU : UserEntity = new UserEntity(); 

      protected function Login_clickHandler(event:MouseEvent):void 
      { 
       authenticateUserResult.addEventListener(ResultEvent.RESULT,activateUser); 
       authenticateUserResult.token = userServiceImpl.authenticateUser(name_.text, pass.text);    
      } 
      private function doInit():void 
      {    
       this.addEventListener(KeyboardEvent.KEY_UP, handleKeyStrokes); 

      } 

      public function handleKeyStrokes(evt:KeyboardEvent):void 
      { 
       if(evt.keyCode == Keyboard.ENTER) 
       {     
        authenticateUserResult.addEventListener(ResultEvent.RESULT,activateUser); 
        authenticateUserResult.token = userServiceImpl.authenticateUser(name_.text, pass.text);  
       } 
      } 

      private function activateUser(event:Object):void{ 
       var user:UserEntity = authenticateUserResult.lastResult as UserEntity; 
       if(user) 
       { 
        if(user.enabled) 
        { 
         CurrentUser.currentUser=user; 
         PopUpManager.removePopUp(this); 
         currentU = user; 
         dispatchEvent(new CloseEvent(CloseEvent.CLOSE, true, false)); 
        } 
        else 
        { 
         errorHbox.visible = true; 
         errorLabel.text = "this user account is disabled"; 
         name_.text = ""; 
         pass.text = ""; 
        } 

       } 
       else 
       { 
        errorHbox.visible = true; 
        name_.text = ""; 
        pass.text = ""; 
       } 

      } 

      protected function authenticateUser(arg0:String, arg1:String):void 
      { 
       authenticateUserResult.token = userServiceImpl.authenticateUser(arg0, arg1); 
      } 


     ]]> 
    </fx:Script> 
    <s:states> 
     <s:State name="forgivepasswordState"/> 
     <s:State name="index"/> 

    </s:states> 


    <mx:HBox id="errorHbox" visible="false" width="98%" horizontalAlign="center" paddingLeft="10" 
      paddingTop="10" verticalAlign="middle"> 
     <s:Image width="32" height="32" source="@Embed('assets/warning.png')"/> 
     <s:Label id="errorLabel" color="red" fontSize="12" fontWeight="bold" 
       text="Wrong Username/Password combination"/> 
    </mx:HBox> 
    <!--<s:Label x="10" y="13" color="#F6800E" fontSize="14" 
    text="Your session has been expired, please Log in again"/>--> 
    <!--<mx:TextInput id="name_" x="192" y="43" width="157" height="22" text=""/> --> 
    <mx:TextInput id="name_" x="189" y="42" width="159" fontSize="15" fontWeight="normal" text=""/> 
    <mx:TextInput id="pass" x="191" y="71" width="158" displayAsPassword="true"/> 
    <mx:Label x="95" y="44" width="86" height="21" color="#024C9E" fontSize="12" text="User name"/> 
    <mx:Label x="96" y="74" width="65" height="21" color="#024C9E" fontSize="12" text="Password"/> 
    <s:Button id="linkBtnForgPwd" left="10" bottom="28" width="157" label="I forgot my password" 
      color="#000000" cornerRadius="5" 
       enabled="true" fontSize="12" icon="assets/lock_key.png" 
       skinClass="spark.skins.spark.ButtonSkin" styleName="linkButton"/> 
    <s:Button x="191" y="114" width="157" label="Log In" click="Login_clickHandler(event)" 
       cornerRadius="5" fontSize="12"/> 
    <s:Image x="7" y="115" width="29" height="20" source="assets/forgot_icon.png"/> 

</s:TitleWindow> 

我已经纠正了这个代码,但我想它当此按钮,用户点击“我忘记了密码”看起来像它出现在弹出的面板中的代码在屏幕截图中提到

![<?xml version="1.0" encoding="utf-8"?> 
<s:TitleWindow 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:services="services.*" 
       x="400" y="400" width="400" height="196" cornerRadius="10" 
       creationComplete="doInit();" fontSize="12" title="Authentication" xmlns:local="*"> 
    <fx:Declarations> 
     <s:CallResponder id="authenticateUserResult"/> 
     <services:UserServiceImpl id="userServiceImpl" 
            fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" 
            showBusyCursor="true"> 
      <services:channelSet> 
       <s:ChannelSet> 
        <s:AMFChannel uri="http://localhost:8080/SmartSupport/messagebroker/amf"/> 
       </s:ChannelSet> 
      </services:channelSet> 
     </services:UserServiceImpl> 
     <s:CallResponder id="setMyStringResult"/> 
     <services:MySessionHandler id="mySessionHandler" 
            fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" 
            showBusyCursor="true"> 
      <services:channelSet> 
       <s:ChannelSet> 
        <s:AMFChannel uri="http://localhost:8080/SmartSupport/messagebroker/amf"/> 
       </s:ChannelSet> 
      </services:channelSet> 
     </services:MySessionHandler> 

      <s:CallResponder id="authenticationResp"/> 

     <!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). --> 
    </fx:Declarations> 


    <fx:Script> 
     <!\[CDATA\[ 
      import com.roamsmart.acl.CurrentUser; 

      import mx.controls.Alert; 
      import mx.core.Application; 
      import mx.core.FlexGlobals; 
      import mx.events.CloseEvent; 
      import mx.managers.PopUpManager; 
      import mx.rpc.events.ResultEvent; 

      import valueObjects.UserEntity; 

      \[Bindable\] 
      public var currentU : UserEntity = new UserEntity(); 

      protected function Login_clickHandler(event:MouseEvent):void 
      { 
       authenticateUserResult.addEventListener(ResultEvent.RESULT,activateUser); 
       authenticateUserResult.token = userServiceImpl.authenticateUser(name_.text, pass.text);    
      } 
      private function doInit():void 
      {    
       this.addEventListener(KeyboardEvent.KEY_UP, handleKeyStrokes); 

      } 

      public function handleKeyStrokes(evt:KeyboardEvent):void 
      { 
       if(evt.keyCode == Keyboard.ENTER) 
       {     
        authenticateUserResult.addEventListener(ResultEvent.RESULT,activateUser); 
        authenticateUserResult.token = userServiceImpl.authenticateUser(name_.text, pass.text);  
       } 
      } 

      private function activateUser(event:Object):void{ 
       var user:UserEntity = authenticateUserResult.lastResult as UserEntity; 
       if(user) 
       { 
        if(user.enabled) 
        { 
         CurrentUser.currentUser=user; 
         PopUpManager.removePopUp(this); 
         currentU = user; 
         dispatchEvent(new CloseEvent(CloseEvent.CLOSE, true, false)); 
        } 
        else 
        { 
         errorHbox.visible = true; 
         errorLabel.text = "this user account is disabled"; 
         name_.text = ""; 
         pass.text = ""; 
        } 

       } 
       else 
       { 
        errorHbox.visible = true; 
        name_.text = ""; 
        pass.text = ""; 
       } 

      } 

      protected function authenticateUser(arg0:String, arg1:String):void 
      { 
       authenticateUserResult.token = userServiceImpl.authenticateUser(arg0, arg1); 
      } 


     \]\]> 
    </fx:Script> 
    <s:states> 
     <s:State name="forgivepasswordState"/> 
     <s:State name="index"/> 

    </s:states> 


    <mx:HBox id="errorHbox" visible="false" width="98%" horizontalAlign="center" paddingLeft="10" 
      paddingTop="10" verticalAlign="middle"> 
     <s:Image width="32" height="32" source="@Embed('assets/warning.png')"/> 
     <s:Label id="errorLabel" color="red" fontSize="12" fontWeight="bold" 
       text="Wrong Username/Password combination"/> 
    </mx:HBox> 
    <!--<s:Label x="10" y="13" color="#F6800E" fontSize="14" 
    text="Your session has been expired, please Log in again"/>--> 
    <!--<mx:TextInput id="name_" x="192" y="43" width="157" height="22" text=""/> --> 
    <mx:TextInput id="name_" x="189" y="42" width="159" fontSize="15" fontWeight="normal" text=""/> 
    <mx:TextInput id="pass" x="191" y="71" width="158" displayAsPassword="true"/> 
    <mx:Label x="95" y="44" width="86" height="21" color="#024C9E" fontSize="12" text="User name"/> 
    <mx:Label x="96" y="74" width="65" height="21" color="#024C9E" fontSize="12" text="Password"/> 
    <s:Button id="linkBtnForgPwd" left="10" bottom="28" width="157" label="I forgot my password" click="this.currentState='forgivepasswordState'" 
      color="#000000" cornerRadius="5" 
       enabled="true" fontSize="12" icon="assets/lock_key.png" 
       skinClass="spark.skins.spark.ButtonSkin" styleName="linkButton"/> 
    <s:Button x="191" y="114" width="157" label="Log In" click="Login_clickHandler(event)" 
       cornerRadius="5" fontSize="12"/> 
    <s:Image x="7" y="115" width="29" height="20" source="assets/forgot_icon.png"/> 
    <local:forgotPassword includeIn="forgivepasswordState"/> 

</s:TitleWindow>][1] 
+0

请问您能告诉我们什么不起作用吗?你预期的结果是什么?究竟发生了什么? – JeffryHouser

回答

0

我看不到任何代码,您尝试更改状态。你只需要在“忘记图标”图像上添加一个事件监听器?

<s:Image x="7" y="115" width="29" height="20" source="assets/forgot_icon.png" click="{currentstate='forgivepasswordState'}"/> 
+0

我纠正了它,但我希望导航到面板上,当我点击按钮出现在第一次,当我点击按钮没有什么 – hana

+0

这听起来像你的状态设置错了,然后 – JeffryHouser

+0

但我让状态点击! – hana