If your Flash Media Server is on the same machine than the one your testing your application from, you should change the URL of server with rtmfp://localhost/streamExample
If your server is on another machine, then you just have to replace localhost
with the IP address of the machine running the server.
You should also add the event listener on your NetConnection
before you perform the connect()
call.
To help you known the reason of the failure, you might want to trace the description of your event as well.
Here is a sample with all these indications:
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netHandler);
nc.connect("rtmfp:/localhost/streamExample");
function netHandler(event:NetStatusEvent):void
{
switch (event.info.code)
{
case "NetConnection.Connect.Success":
{
connectButton.label = "Disconnect";
connectButton.enabled = true;
sendButton.enabled = true;
onConnect();
break;
}
case "NetConnection.Connect.Closed":
{
connectButton.label = "Connect";
connectButton.enabled = true;
sendButton.enabled = false;
nc.close();
break;
}
case "NetConnection.Connect.Failed":
{
trace("Sorry your connection failed");
trace("Reason is: " + event.info.description);
break;
}
case "NetConnection.Connect.Rejected":
{
trace("Oops the connection has been rejected");
break;
}
}
}