2 Replies Latest reply on Aug 19, 2010 2:54 AM by kiran7881

    About Flex 3 POPUPMANAGER

    kiran7881 Level 1

      Hi ,


      Yesterday i got a chance to look at FLex's POPUPManager . i have used its createUo and removePop Methods to dsiplay Containers on to the Form .
      I couldn't find it this POPUpManger useful , because i feel that the same thing can be achivied by ActionScript , so please let me know if i am wrong .

       

      Please correct me if i am missing anything related to this related to where it is exactly useful .

       

      Thanks in advnace .
        • 1. Re: About Flex 3 POPUPMANAGER
          ShardulSingh Level 3

          Hi Kiran,

           

          This is with Reference to you doubt about popup manager and the project in which you want the Login window. Use user name and password both as

          'admin '. I have worked on those classes which you are having in your another thread.You work either in action script or mxml you have to use

          Popup manager for this purpose.

           

          Let me know if you have any doubt.

           

           

           

          LoginEvent.as

           

          package events
          {
              import flash.events.Event;
              import vo.User;
              public class LoginEvent extends Event
              {
                  public static const LOGIN_EVENT:String = "LoginEvent";
                  public var user : User;
                
                  public function LoginEvent(type:String,user:User,bubbles:Boolean = false, cancelable:Boolean = false)
                  {
                      super(type,bubbles,cancelable)
                      this.user = user;
                  }
                  override public function clone():Event
                  {
                      return new LoginEvent(type,user, bubbles, cancelable);
                  }

           

           

           

              }
          }

           

           

           

          User.as

          package vo
          {
              public class User
              {
                
                  public var uname:String;
                  public var pass:String;
                
                  public function User()
                  {
                    
                  }

           

              }
          }

           

           

           

          LoginWindow.mxml

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" title="Login">
          <mx:Script>
              <![CDATA[
                  import events.LoginEvent;
                  import vo.User;
                  public function CallMe():void
                  {
                         var user:User = new User();
                      user.uname = UITI.text;
                      user.pass = PWDTI.text;
                      systemManager.dispatchEvent(new LoginEvent(LoginEvent.LOGIN_EVENT,user));
                  }
              ]]>
          </mx:Script>
              <mx:Form x="183" y="179">
                  <mx:FormItem label="UserName">
                      <mx:TextInput  id="UITI" />
                  </mx:FormItem>
                  <mx:FormItem label="Password">
                      <mx:TextInput id="PWDTI"/>
                      <mx:Button label="Button" click="CallMe()"/>
                  </mx:FormItem>
              </mx:Form>
          </mx:TitleWindow>

           

           

          Test.mxml

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300" backgroundColor="0xDDDDDD">
             <mx:Label text="This is Test Module."/>
          </mx:Module>

           

           

           

          MainApplication.mxml

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
          <mx:Script>
              <![CDATA[
                  import mx.managers.PopUpManager;
                  import mx.controls.Alert;
                  import vo.User;
                  import events.LoginEvent;
                 
                  var loginWindow:LoginWindow
                  private function onCreationComplete() :void
                  {
                      loginWindow = LoginWindow(PopUpManager.createPopUp(this, LoginWindow, true));
                      loginWindow.move(((Application.application.width/2)-(loginWindow.width/2)),((Application. application.height/2)-(loginWindow.height/2)));

           

                      systemManager.addEventListener(LoginEvent.LOGIN_EVENT, onSuccessfullLogin )
                  }
                 
                  private function onSuccessfullLogin(event : LoginEvent) : void
                  {
                      var user : User = event.user as User;
                      if( user.uname == 'admin'  && user.pass == 'admin')
                      {
                          testModuleLoader.url = "Test.swf";
                          PopUpManager.removePopUp(loginWindow);
                      }
                      else
                      {
                          Alert.show("Invalid userName or password");
                      }
                  }
              ]]>
          </mx:Script>

           

            
             
            <mx:ModuleLoader id="testModuleLoader" width="500" height="500" creationComplete="onCreationComplete()">
               
            </mx:ModuleLoader>
          </mx:Application>

           

           

           

           

           

           

           

           

           

          with Regards,

          Shardul Singh Bartwal

          • 2. Re: About Flex 3 POPUPMANAGER
            kiran7881 Level 1

            Thanks for your time for posting the whole code as understable to me .

            This looks great , i will try this at  home and let you know .

            In my work place i dont have Flex Builder as i work on java only .