What you describe sounds like it should work.  If you suspect scoping issues, you are probably correct.  Use delegate() to make sure the handler function executing the viewstack.selectedIndex =  n call knows about the viewstack.

 

Tracy

 


From: Blake Kadatz [mailto:[EMAIL PROTECTED]
Sent: Monday, March 21, 2005 5:15 PM
To: [email protected]
Subject: [flexcoders] Proper login window handling?

 

Hello,

 

I've build a LoginWindow.mxml consisting of a <mx:TitleWindow ...> tag and related code.  I call this from my main application as such:

 

  function show_login():Void
  {
   var parent = this;
   var isModal:Boolean = true;
   var initObj = {};
   var login = PopUpManager.createPopUp(parent, LoginWindow, isModal, initObj);
   login.parentObject = this;  // store a reference to this Application
   login.centerPopUp();
  }

So far so good.  When the user wants to login, I call a remote object with the username and password supplied by the user which queries a database and passes the return value to a loginResult function:

 

  function loginResult(result):Void
  {
   if (result == true)
   {
    // switch to a different panel in the stack
    //
    parentObject.main_stack.selectedChild = parentObject.login_ok_panel;
    this.deletePopUp();
   }
   
   else
   {
    login_result.text = "Sorry, your login details are incorrect.";
   }
  }

And this works fine, but it seems like a hack. I originally wanted to get this to work with events.  I setup an event handler on the "login" variable, the LoginWindow fires off an event if the login is successful, and the application handles the event and switches to a different panel in the stack.  The problem is, this didn't work.  I could display an alert dialog, but the call to switch the stack didn't execute.  I assume this has something to do with how it's being references (eg: event handlers are outside of the scope of the code in which they're created) but after an hour of fiddling with broadcast handlers and various other mechanisms, I couldn't seem to get main_stack to update.

 

Is this the only way to do it, is the event model cleaner, or is there a better methodology for displaying modal dialogs like a login screen?  Any pointers would be appreciated.

 

Thanks,

 

Blake




Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to