Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Library to help Flash, Flex and ActionScript clients connect to Socket.IO servers.
ActionScript Perl
Branch: 0.7.x
Pull request Compare This branch is 16 commits ahead of simb:0.7.x.

Removed unwanted trace statements. Removed dependence on MonsterDebug…

…ger. Added method getConnectionUrl with intention of allowing FlashSocket to be extended.
latest commit 050562bcd6
@jimib authored


This isn't the original work of Jimib, this has been forked from git:// which had an initial dependence on gimite/web-socket-js The original project was only compatible with Flex and I needed a pure AS3 solution so I have tinkered the code and replaced a couple of Flex only classes. The most notable substitution has been of the mx.utils.URLUtil with The 2 classes are not directly interchangeable so I do expect some problems as a result.



Flash library to facilitate communication between Flex applications and Socket.IO servers.

The actual websocket communication is taken care of by my fork of gimite/web-socket-js project.

This project wraps that and facilitates the hearbeat and en/decoding of messages so they work with Socket.IO servers


Because this project makes use of git submodules you must make use of the recursive clone.

git clone --recursive git://


Because this library is dependent on the websocket library, you must add the support/websocket-js path to you source path in flash builder or your build files.


For 0.7 and 0.8 you will need to use the Beta swc that you can find in the downloads section. Currently in beta.

An example of a flex application connecting to a server on localhost is below

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="" 
               xmlns:mx="library://" minWidth="955" minHeight="600"
        <s:VerticalLayout />
        <!-- Place non-visual elements (e.g., services, value objects) here -->
            import com.pnwrain.flashsocket.FlashSocket;

            import mx.controls.Alert;

            protected var socket:FlashSocket;

            protected function application1_creationCompleteHandler(event:FlexEvent):void

                socket = new FlashSocket("localhost:8080");
                socket.addEventListener(FlashSocketEvent.CONNECT, onConnect);
                socket.addEventListener(FlashSocketEvent.MESSAGE, onMessage);
                socket.addEventListener(FlashSocketEvent.IO_ERROR, onError);
                socket.addEventListener(FlashSocketEvent.SECURITY_ERROR, onError);

                socket.addEventListener("my other event", myCustomMessageHandler);

            protected function myCustomMessageHandler(event:FlashSocketEvent):void{
      'we got a custom event!')    

            protected function onConnect(event:FlashSocketEvent):void {



            protected function onError(event:FlashSocketEvent):void {

                setStatus("something went wrong");


            protected function setStatus(msg:String):void{

                status.text = msg;

            protected function clearStatus():void{

                status.text = "";
                this.currentState = "";


            protected function onMessage(event:FlashSocketEvent):void{

                trace('we got message: ' +;
                socket.send({msgdata:},"my other event");


    <s:Label id="status" />
    <s:Label id="glabel" />
Something went wrong with that request. Please try again.