Declare ns as a private var in the beginning, since you have it as a local variable.

private var ns:NetStream;
ns = new NetStream(nc);