Connect SmartFox Server using Action Script 3 In Flash Builder 4.6

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.

sfs.connect(“127.0.0.1″,9339);

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.

package
{
	import flash.display.Sprite;

	import it.gotoandplay.smartfoxserver.*;

	public class SumartFox extends Sprite
	{
		private var sfs:SmartFoxClient;

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

			sfs.connect("127.0.0.1",9339);

			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.

Note : Premium users can able to download all the scripts* without any waiting time. So please become premium user.    

If you want any of my script need to be customized according to your business requirement,

Please feel free to contact me [at] muni[at]smarttutorials.net

Note: But it will be charged based on your customization requirement

* - Except Invoice Script

Get Hottest Updates, Scripts & Other Useful Resources to your Email

  • http://www.happyquotesworld.com muni

    nice script…….thanks

Get Instant Script Download Access!