2012-01-26 7 views
0

main.acsを呼び出してすべてのユーザーにメッセージをブロードキャストするコードがあります。メッセージをすべてのユーザーにブロードキャストすると、bcStopStreaming関数が呼び出されることはありません。サーバーからのAS3コールバックが機能しない

サーバーサイドコード:

application.onConnect = function(client) { 
    application.acceptConnection(client); 

    client.stopStreaming = function() { 
     trace("#stopStreaming# called"); 
     application.broadcastMsg("bcStopStreaming"); 
    } 

    client.startStreaming = function() { 
     trace("#startStreaming# called"); 
     application.broadcastMsg("bcStreaming"); 
    } 
} 

接続ボタン:

public function btnConnectHandler(event:MouseEvent):void 
{ 
    nc = new NetConnection(); 
    nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 

    nc.connect("rtmp://"+hostName+"/test"); 
    nc.client = new Object(); 

    nc.client.bcStreaming = function(){ 
     trace("Started Streaming"); 
    }; 

    nc.client.bcStopStreaming = function(){ 
     trace("Stopped Streaming"); 
    }; 
} 

切断]ボタン:私が得る

public function btnDisconnectHandler(event:MouseEvent):void { 
    nc.call("stopStreaming", null); 
    nc.close(); 
} 

エラー:

Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback bcStreaming. error=ReferenceError: Error #1069: Property bcStreaming not found on test and there is no default value. 
at test/btnConnectHandler() 

答えて

1

クライアントが正しく設定されていません。
そして、インライン関数の使用を中止してください。

public function btnConnectHandler(event:MouseEvent):void{ 
    nc = new NetConnection(); 
    nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 

    nc.connect("rtmp://"+hostName+"/test"); 
    var myClient = new Object() 

    myClient.bcStreaming = this.bcStreaming; 
    myClient.bcStopStreaming = this.bcStopStreaming; 
    nc.client = myClient; 
} 
public function bcStreaming(){ 
    trace("Started Streaming"); 
} 

public function bcStopStreaming(){ 
    trace("Stopped Streaming"); 
} 

nc.client

関連する問題