Chapter 24 Example 4
forked from Chapter 24 Example 3 (diff: 26)
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sQcG
*/
package {
import com.actionscriptbible.Example;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.Socket;
public class ch24ex4 extends Example {
protected var sock:Socket;
public function ch24ex4() {
sock = new Socket();
sock.addEventListener(Event.CONNECT, onSocketOpen);
sock.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
sock.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
sock.connect("www.actionscriptbible.com", 80);
}
protected function onSocketOpen(event:Event):void {
trace("Connected succesfully!");
sock.close();
}
protected function onIOError(event:IOErrorEvent):void {
trace("ERROR:", event.text);
sock.close();
}
protected function onSecurityError(event:SecurityErrorEvent):void {
trace("ERROR:", event.text);
sock.close();
}
}
}
