我正在尝试在Flash CS6中的ActionScript3项目中使用DatagramSocket
,但在编译之后,我收到此错误:
DatagramSocketClass.as,第24行1046:未找到类型或不是编译时常量:
DatagramSocketDataEvent
。
这是我的DatagramSocketClass.as
代码:
package com.example.udp
{
import flash.display.Sprite;
import flash.events.DatagramSocketDataEvent;
import flash.events.Event;
import flash.events.*;
import flash.net.DatagramSocket;
import flash.utils.ByteArray;
public class DatagramSocketClass extends Sprite
{
private var datagramSocket:DatagramSocket = new DatagramSocket();
public function World()
{
datagramSocket = new DatagramSocket();
datagramSocket.bind("1111","127.0.0.1");
datagramSocket.addEventListener(DatagramSocketDataEvent.DATA, dataReceived );
datagramSocket.receive();
}
private function dataReceived( event:DatagramSocketDataEvent ):void
{
//Read the data from the datagram
log("Received");
}
}
}
我的代码出了什么问题?