Tutorial: Socket server with Flash and Node.js
Programming with sockets seems to be an intimidating venture for many developers. However, with AS 3 and Node.js, it really isn’t too difficult. In this tutorial you will set up a simple socket server using Node.js and connect to it with a Flash-based client. When the project is complete, you’ll be able to see data being transmitted from Flash to the server and back to Flash again - Booyah!
To get started, you’ll first need to download Node.js. If you’re on a Windows box, you can get the download right here. If not, check out this wiki page for instructions on how to get it on your system. I wrote this tutorial on my Windows 7 machine, so the instructions will target that platform, though you can still follow along and use the appropriate paths on your own machine regardless of which platform you’re using.
1) hit the Windows key + r to bring up the Run box
2) type cmd in the box and hit enter
With the command window open, we need to navigate to the Node.js bin directory; that is where we saved our helloworld.js file. If you created a nodeJS directory on your C drive as I have done above then type the following in the command window:
If you created your directory in a different place, you’ll need to adjust the path accordingly. Now that we’re in the right place, we need to tell the Node program to execute our script. We can do this by issuing the command like so:
With any luck, you’ll see the words “Hello, World” printed out in the console window as shown below.
If everything worked, then you’re ready to move on. If not, try repeating the steps and make sure you’ve installed Node.js in the right place.