开发者

AS3 how to return EventListener value

If I have code that looks like this:

public function getNetStreamPublishClientList():Array
{
    var ncStreamListResults = new Object()
    ncStreamListResults.onResult = function(list:Array)
    {
        //this needs to be returned from getNetStreamPublishClientList
        return list;
    }

    this.nc.call("getStreamClientIds", 
                 new Responder(ncStreamListResults.onResult),
                 this.streamName);
}

how can I return the valu开发者_Go百科e of list from getNetStreamPublishClientList?


use global item for list


It looks like you won't be able to know the value of list at the point that getNetStreamPublishClientList() finishes executing.

This is because the nc object will probably not have finished its work by that time, and in that case the completion handler (currently assigned to be onResult) won't have been called.

Whatever is waiting on the result of this function, I'd change it to wait for an event. Possibly use a member function to act as the onResult handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜