0

I have this function structure:

function doStuff():Boolean {
    variables = new LoadVars();
    variables.anything = "xxx";
    variables.onLoad = function(success) {
        if (success) {
            doStuff;
            results = true;
        } else {
            results = false;
        }
    };
    variables.sendAndLoad(url, variables, "POST");
    return results;
}

Function works fine, but can“t return properly the 'results' value. Any idea?

Jairo Filho
  • 342
  • 5
  • 17

1 Answers1

0

Not sure why you need to return anything. What about this?

function loadStuff():Void
{
    var variables = new LoadVars();
    variables.anything = "xxx";
    variables.onLoad = onStuffLoaded;

    variables.sendAndLoad(url, variables, "POST");
}

function onStuffLoaded( success ):Void
{
    if (success)
    {
        doStuff();
    }
    else
    {
        handleNotDoingStuff();
    }
}
Ribs
  • 1,449
  • 2
  • 13
  • 27