Connect SmartFox Server using Action Script 3 In Flash Builder 4.6

  September 3, 2012   by:  muni   1 Comment

In this tutorial we are going to connect SmartFox Server using Action Script 3 in Flash Builder 4.6. Mostly you won’t get action script 3 code to connect smartfox server, here i’ll provide action script 3 source code at end of the tutorial.

At the end of the tutorial you came knw following this…

1. Action Script 3 code to connect SmartFox Server.

2. Action Script 3 SmartFox Server API.

3. Action Script 3 event listeners and etc..

Step 1: Create action script 3 project by going File -> New -> Action Script project.

Step 2: Once I created Action Script project, then I imported following action script packages in the project to utilize SmartFox Server  api to connect with server.

import it.gotoandplay.smartfoxserver.*;

Step 3: Then I instantiated SmartFoxClient class object using following syntax.

private var sfs:SmartFoxClient = new SmartFoxClient();

Step 4: By using connect() method we made a connection request to SmartFox Server.


Step 5: Once the connection is success, the following event is triggered to indicate the connection was success.

sfs.addEventListener(SFSEvent.onConnection, onConnect);

Here is the whole source code.

	import flash.display.Sprite;

	import it.gotoandplay.smartfoxserver.*;

	public class SumartFox extends Sprite
		private var sfs:SmartFoxClient;

		public function Summa()
			sfs= new SmartFoxClient();


			sfs.addEventListener(SFSEvent.onConnection, onConnect);

		private function onConnect(evt:SFSEvent):void{

		trace('connection was made successful');

If any problem to make a connection to the Server, let me know using below comment box.

  • muni

    nice script…….thanks