开发者

AS3 how to return EventListener value

开发者 https://www.devze.com 2023-01-07 02:24 出处:网络
If I have code that looks like this: public function getNetStreamPublishClientList():Array { var ncStreamListResults = new Object()

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

精彩评论

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