PDA

View Full Version : Problem with NetConnection and Flash Media Server


bbonnet18
11-20-2009, 08:51 PM
Hi, I'm attempting to place a function on a NetConnection instance, and from everything I've read, I should be able to do that. Unfortunately, I'm getting an error when I compile. Here's my code, and my error is below the code, please let me know if you have a solution. Thanks for the help!

import mx.rpc.events.ResultEvent
import flash.net.NetConnection;
import flash.net.navigateToURL;
import flash.events.NetStatusEvent;
import flash.events.StatusEvent;
import flash.text.TextField;

public var nc:NetConnection;

// init is called on creationComplete
public function init():void{
nc = new NetConnection;
nc.addEventListener(NetStatusEvent.NET_STATUS,onCo nnect);
nc.connect("rtmp://localhost/FMSTesting");

}


public function onConnect(event:NetStatusEvent):void{
myText.text = nc.connected + event.info.code;
}


//nc.myFunction is the function that will be called
//from the main.asc server side file and this is where I get
// the red x in Flex Builder 3 telling me there's an error

nc.myFunction = function():void{

}

error generated by the nc.myFunction line is:

1119:Access of possibly undefined property myFunction through a reference with static type flash.net:NetConnection

I tried putting the function declaration inside the onConnect handler and inside the init function, niether will remove the error.