1046: Type was not found or was not a compile-time constant: ServerSocketConnectEvent

妖精的绣舞 提交于 2021-02-10 23:19:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!