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>
<allow-access-from domain="*" />
» 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")
doc index |