38
Chapter 2: Using Flash Remoting ActionScript
You use the constructor for the Service class to create a new Service object. The following example
shows how to create a Service object (
new Service()
) while simultaneously creating a gateway
connection ("
http://localhost:8300/flashservices/gateway
") and a reference
(
custService
) to a remote service ("
CustomerInfo
"):
custService = new Service("http://localhost:8300/flashservices/gateway”,
new Log(),
"CustomerInfo",
null,
null);
When you create a gateway connection in this manner, you can access the Connection object
through the
connection
property of the Service object. For more information, see the Service
class in Flash Remoting ActionScript Dictionary Help.
Specifying the gateway connection in a web page
You specify the gateway in the web page that loads your SWF file by adding entries in the
OBJECT
tag that calls the SWF file. You must use different techniques for Microsoft Internet Explorer and
Netscape Navigator browsers:
•
To specify the gateway for Internet Explorer, specify the gateway URL as a
flashvars
parameter in an HTML
PARAM
tag inside the
OBJECT
tag body.
•
To specify the gateway for Netscape, specify the gateway URL as a
flashvars
attribute to the
HTML
EMBED
tag that specifies the Flash application.
The following HTML example runs the myMovie.swf Flash application and specifies http://apps.
myCompany.com/flashservices/gateway as the URL for the Flash Remoting services gateway. The
first highlighted line contains the code for Internet Explorer. The second highlighted line
contains the code for Netscape.
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.
cab#version=6,0,0,0"
WIDTH="100%"
HEIGHT="100%"
id="MyMovie">
<PARAM NAME="flashvars" VALUE="gatewayUrl=http://apps.myCompany.com/
flashservices/gateway">
<PARAM NAME=movie VALUE="MyMovie.swf">
<PARAM NAME=quality VALUE="high">
<PARAM NAME=bgcolor VALUE="#000099">
<EMBED src="MyMovie.swf"
FLASHVARS="gatewayUrl=http://apps.mycompany.com/flashservices/gateway"
quality=high bgcolor="#000099"
WIDTH="100%"
HEIGHT="100%"
NAME="movieName"
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>