Macromedia flash media server 2-client-side actionscript language reference for flash media server 2 ユーザーズマニュアル

ページ / 156
NetConnection class
73
There are a few things you can do to prevent the security policies from inconveniencing you 
or your users. The first, and easiest, is to use a target URI that doesn’t specify a server name. 
(This is applicable only if the Flash Media Server and web server are running from the same 
IP address.) To do so, leave off the second slash in the 
targetURI
 parameter. For example, the 
following commands will make Flash Player attempt to connect to the same host and domain 
as the web server the SWF file was served from: 
my_nc = new NetConnection();
my_nc.connect("rtmp:/myApp");
Second, there is a bit of JavaScript you can use in your HTML page to avoid the security 
problem. Assuming the SWF file uses a fully qualified domain name URL to access the Flash 
Media Server, this JavaScript redirects the web page to an explicitly named full URL, like this:
<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 instance, flashcom.mycorp.com could map to the 
machine running the Flash Media Server and having 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.)
Example
The following example connects over the RTMP protocol to the default instance of the 
funAndGames
 application located on the 
real
 host of the 
macromedia
 server using the default 
port:
my_nc = new NetConnection();
my_nc.connect("rtmp://real.macromedia.com/funAndGames");
The following example connects over the RTMPT protocol to the 
room_01
 application 
instance of the 
chat
 application using the default port. In this example, the Flash SWF file is 
served from the same host and domain as Flash Media Server, so the host parameter is 
omitted.
my_nc = new NetConnection();
my_nc.connect("rtmpt:/chat/room_01");