Flash Builder 4: Call main function from a component function

Posted by hyper on Stack Overflow See other posts from Stack Overflow or by hyper
Published on 2010-04-06T05:34:31Z Indexed on 2010/04/06 5:43 UTC
Read the original article Hit count: 351

Filed under:
|
|
|
|

i try to make a login sistem in flex, and my app looks like this:

i have a main.mxml. when the app loads, a function named "start" is called. it verifies if the user is logged in or not. if "true" the user is redirected to a dashboard, if "false", a component named login is loaded.

my login.mxml component has 2 input boxes (user & pass) and a "Submit" button. when the button is pressed a function named "send_login" sends the user and the pass values to the server.

My problem sounds like this: when i press the Submit button in my login component, after user and pass are sended... i want to call again the "start" function from my main.mxml to check again if the user is logged in or not...

i need some kind of as2 "_root"

this is how my code looks:

main.mxml

public function start():void {
  currentState="Start";
  loginstatus();
 }

login.mxml

private function send_login(event:Event):void {

 ... bla bla send user and pass....
 scriptLoader.addEventListener(Event.COMPLETE, handleLoadSuccessful);
}

private function handleLoadSuccessful(evt:Event):void { 

 trace("Data sent.");
  start();  <-- HERE i want to call the function from main.mxml
}

any help is welcomed!

© Stack Overflow or respective owner

Related posts about flex

Related posts about flash