问题
I am trying to get the adobe AIR SocketServer class to work. When I pasted in this code from the adobe website:
import flash.net.ServerSocket;
import flash.events.ServerSocketConnectEvent;
function onConnect(e:ServerSocketConnectEvent):void
{
var incomingSocket:Socket = e.socket;
}
var server:ServerSocket = new ServerSocket();
server.addEventListener(Event.CONNECT, onConnect);
server.bind(8888);
I got the error saying that the SocketServerConnectEvent could not be found. However, there is an import statement importing precisely that class at the line above it. What am I missing here?
回答1:
This is happening because when you launch your Air app it is trying to run it in the normal flash player and it obviously doesn't have access to those classes.
There was an article about it let me see if I can find it. Well can't find it.
If you run it from flash (cs5 etc) it should run fine. In flex builder I think you hit ctrl+f11.
I use flash develop most of the time and I am not sure how you would do it there. If that is what you use then the reason I stated above is why it is happening. (confirmed on my box)
来源:https://stackoverflow.com/questions/5023816/1046-type-was-not-found-or-was-not-a-compile-time-constant-serversocketconnect