Flash Media Server |
|||
| Developing Media Applications > Using Media Classes > The NetConnection class (client-side) | |||
If an HTML page containing a Flash application (SWF file) is accessed with a different domain name than the domain name the SWF file uses to access Flash Media Server, the connection to Flash Media Server will not be successful. This is a security feature of Flash Player. But in some cases, this may be inconvenient.
For example, if a web page containing a Flash application is served on an intranet from http://deptserver.mycorp.com, it can also be accessed from http://deptserver. However, if the page is accessed from the URL http://deptServer/tcpage.htm, but the SWF file specifies deptServer.mycorp.com as the targetURI parameter in the NetConnection.connect() method, the SWF file will not successfully connect to Flash Media Server. Similarly, if the web page and SWF file are accessed from the URL http://deptserver.mycorp.com/tcpage.htm, but the SWF file uses the URL rtmp://deptserver as the targetURI parameter, the SWF will not connect to the server.
You can do a few things to prevent the security policies from inconveniencing you or your users. The easiest way is not to include a server name in the targetURI parameter. (This is applicable only if Flash Media Server and the web server are running on the same machine.) To do so, leave off the second slash in targetURI. For example, the following commands will instruct Flash Player to connect to the same host and domain as the web server the SWF file was served from.
nc = new NetConnection();
nc.connect("rtmp:/myApp");
Another way to avoid the security problem is to use a bit of JavaScript in your HTML page. Assuming the SWF file uses a fully qualified domain name URL to access Flash Media Server, the following JavaScript redirects the web page to an explicitly named full URL:
<SCRIPT language="javascript">
// if the URL didn't have the domain on it
if (document.URL.indexOf("mycorp.com") == -1) {
// redirect to a version that does
document.URL="http://deptServer.mycorp.com/tcpage.htm";
}
</script>
Finally, if you own a domain name, have access to the DNS records of that domain name, and have a static IP address for your Flash Media Server, you can create address ("A") records to point a host name to that IP address. For example, flashcom.mycorp.com could map to the computer that is running Flash Media Server and has an IP address provided by your IT department or ISP. Your web pages can continue to be hosted by whatever means you are currently using. ("CNAME" records are recommended if you need to forward traffic to a server that has a DNS-accessible host name but may or may not have a static IP address.)
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/fms/2/docs/00000062.html
Comments
No screen name said on Jan 21, 2006 at 8:13 PM : McKean said on Feb 7, 2007 at 3:57 AM :