从actionscript 2函数返回值

时间:2013-09-17 18:09:43

标签: actionscript-2

我有这个功能结构:

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;
}

函数工作正常,但无法正确返回'结果'值。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

不确定为什么你需要退货。那怎么样?

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();
    }
}