Connect SmartFox Server using Action Script 3 In Flash Builder 4.6

Posted by & filed under ADOBE FLEX, SmartFox Server.

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.

.

Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts

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

Please feel free to contact me [at] muni2explore[at]gmail.com

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

Get Updates, Scripts & Other Useful Resources to your Email

Join 10,000+ Happy Subscribers on feedburner. Click to Subscribe (We don't send spam)
Every Email Subsciber could have access to download 100+ demo scripts & all future scripts.

%d bloggers like this:

Get Instant Script Download Access!