Skip navigation
Im out of ideas
Currently Being Moderated

Asking for user input in the middle of a function

Jun 14, 2012 12:51 PM

Tags: #workflow #user_input

Here's my issue.

 

I need to launch and input window in the middle of a function for user input.  Before I can continue through the function I need a response back from the user first.  Psuedo code below:

 

 

function
{
     function begins
 
     pop up window is launched to ask for user input
 
     function continues after users submits input
 
     user input from pop up window is used in function return value
}

 

 

Let me know if you need more clarification but this is essentially what I'm attempting to do.

 
Replies
  • Currently Being Moderated
    Jun 14, 2012 1:03 PM   in reply to Im out of ideas

    You will need to use a pop up alert set to modal. With a function attached that wait for the alert to be filled and exited

     

     

     

    To follow your code example

     

     

     

    Sorry to be brief but im just about to fall into bed after an 16 h our day J

     

     

     

    Feel free to contact me off forum if you would like some help

     

     

     

    Cheers

     

    glenn

     

     

     

    function

     

    {

     

    function begins

     

    call Alert:

     

    - with modal set to true

     

    - with a return event listener set to call Result_function once the alert window is closed

     

     

     

          .. .. .. All other action now stops while the alert window is displayed

     

    }

     

     

     

    public var userResult;

     

     

     

    function Result_function

     

    {

     

                Get the user input from the returned event

     

                Validate the user input

     

            function continues after users submits input

            user input is saved in a public variable so you can use it somewhere else

            or you just do what you need to do with the user input here

     

     

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 15, 2012 4:13 AM   in reply to Im out of ideas

    The way actionScript works it isn’t really designed to work that way

     

     

     

    Is there any reason why you have to only use one function as you have written

     

     

     

    I think you really do need to split up your code into sections that a, set up the pop-up with  event listeners waiting for the input to be completed, trigger the pop up with user input, then have a handler function that then interprets the results of the user action.

     

     

     

    Trying to force the system into a closed loop while waiting will be a bad idea.

     

     

     

    By using a pop-up or an alert window that is set to be modal, you are effectively stopping your application doing anything else until the user input has been completed, but still not locking the app into a closed loop. Imagine what would happen if you did put the system into a closed loop, the mouse movement wouldn’t be updated, the screen wouldn’t refresh and the system wouldn’t be able to handle your user input. the reason for using async model is you are able to let the system still do all its background task (move the mouse, give inputs focus, keep the screen drawn etc) but still tell a part of your app to ‘wait for input’ before carrying on it execution of your logic

     

     

     

    Do you come from another programming language? Maybe one that uses less of an OOP approach? I only ask, as the method you are describing is much more like how I had to program when  I worked on computers years ago as an assembly programmer.

     

    In actionscript and most other modern languages and Oss you don’t have total control of the system and cant lock it into an action as you describe.

     

    You need to have an asynchronous approach to situations like you describe and let the system run in the back ground while you are waiting for input (or date from a server for that matter)

     

     

     

    Please excuse me if I am telling you things you already know.

     

     

     

    What exactly is your use case for this? Maybe if we knew exactly what you are working on I might be able to offer a solution that would make sense for your particular situation.

     

     

     

    Hope all is going well and please feel free to contact me if you are stuck

     

     

     

     

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points