0

I have been struggling to find a way to do this. Basically, I am committing data to a database that I have assigned all the variables to. However, when it has finished committing that data, I want it to then push to the next view. So far, I can get it to work if I program in another button to push to the next view but I want it to be automated with the one button.

So far my code is:

            protected function btnClientSubmit_clickHandler(event:MouseEvent):void
        {
            repID = RepID.toString();
            CompPass = CompID.toString();
            clientPass = ClientID.toString();
            compaID = parseInt(CompPass);
            sessions.SessionID = SessionID.toString();
            sessions.RepID = parseInt(repID);
            sessions.CompanyID = compaID;
            sessions.CustID = clientID;
            sessions.Status = 'Open';
            createSessionsResult.token = sessionsService.createSessions(sessions);
            createSessionsResult.token = sessionsService.commit();
            navigator.pushView(CheckOut);
        }

It works 100% for committing so that is not a problem and hence I did not include all the other code. My problem comes with the fact that the program is pushing to the next view too soon and it interrupts my data insert.

JESlabbert
  • 160
  • 2
  • 13
  • Why you cant try adding the event listener for the sql connection and then on that event handler function change your screen ? – Triode Mar 05 '12 at 06:22

2 Answers2

0

Flex works with asynchronous event handler. There's always a COMPLETE event for this kind of functions.

Arthur Flower
  • 335
  • 3
  • 12
0

Tried something like a resultHandler function for createSessionsResult ?

import mx.rpc.events.ResultEvent;

<s:CallResponder id="createSessionsResult" result="createSessionsResult_resultHandler(event)"/>

protected function createSessionsResult_resultHandler(event:ResultEvent):void
{
navigator.pushView(CheckOut);
}
Aaron M.
  • 749
  • 8
  • 11