3.1 The Basics

» Running the server

Running the server is a very simple task:

Windows: go in the Start Menu >> programs >> SmartFoxServer and click on "Start"

Unix/Linux/MacOS X: open a terminal window, locate the SmartFoxServer folder and just type ./start

Once the server is running you can monitor it using the Administrator Tool.

» Flash player: connection restrictions and cross-domain policy file.

Flash player version 6 introduced a number of restrictions when trying to connect or access resources outside the domain where the SWF file is published.
In other words it was not possible to connect via XMLSocket to another domain or load assets/variables from a domain other than the one where the movie is located.

For example if your SWF file was published on www.mywebsite.com it would have refused to load some variables from www.anotherwebsite.com

With Flash player version 7 Macromedia added extra restrictions that don't allow connections even to subdomains of the parent domain.

To overcome these limitations cross-domain policy files where introduced: these files are simple xml files that should be published in the web root of the external domain you want to access. When you are pointing the flash player to a resource outside the current domain it will try to load the policy file from the web-root of the external domain and see if it can access the required resource. This is valid for XMLSocket connections, loading of variables, xml files and external movieclips.

Here's an example of a policy file:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
	<allow-access-from domain="www.gotoandplay.it" />
</cross-domain-policy> 

The first 2 lines declare the document type and the following 3 are those you have to edit. In this case we are allowing connections from www.gotoandplay.it domain but you could also allow all domains by substituting the 4th line with this one:

 <allow-access-from domain="*" />

This XML file should be always saved under the name of crossdomain.xml and it should be placed in your web root folder. In the case of www.gotoandplay.it the file should be reachable at this url: http://www.gotoandplay.it/crossdomain.xml

» An easier way. (SmartFoxServer Basic and PRO only)

In Flash Player 7 (7.0.19.0) and later, ActionScript can inform the Flash player of a non-default location for a policy file using System.security.loadPolicyFile.

Let's say you have your SWF file published on www.mywebsite.com and SmartFoxServer running on another machine at the ip address 192.168.0.1
By using this line of Actionscript (before the smartfox.connect() method is invoked) you will be able to automatically authorize the flash player to connect outside the current domain:

System.security.loadPolicyFile("xmlsocket://192.168.0.1:9339")


In other words you're requesting the XML cross-domain policy file from the server itself.
SmartFoxServer can automatically generate a valid xml cross-domain file and deliver it through the socket connection, simplyfing the solution to this problem.
By default this feature is activated. If you need more info please refer to the configuration section 2.1


doc index