MACROMEDIA FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 Spezifikationen Seite 24

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 40
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 23
This is the Title of the Book, eMatter Edition
Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
22
|
Chapter 1: Introduction to Flash Remoting
service, and the onStatus( ) callback function is called if an error occurs. An object
used to receive results from a remote service is called a responder object (or some-
times called a response object).
Another way to trap events is to specify callback functions named the
same as the service name with _Result and _Status appended to it. This
technique, along with more information about callback functions and
responder objects, is covered in Chapters 3 and 4.
The System.onStatus property specifies the function to be called if the Flash Player
cannot connect to the server, as these types of errors are not handled by the onStatus( )
callback function for the remote service call. Example 1-1 sets
System.onStatus to exe-
cute our object’s onStatus( ) function. Once we have created an object and the call-
back functions to receive and process the data returned from the server, we are ready
to call the remote service.
Section 4 of Example 1-1 makes a connection to the server by passing in
myURL (ini-
tialized earlier) to the NetServices.createGatewayConnection( ) function. The server
connection information is stored in the
myServer variable. The example then gets a
reference to the remote service, which we store in the variable
myService, by calling
the getService( ) method on the
myServer variable initialized in the previous step. In
the call to getService( ), we pass
myServicePath to access the desired service and pass
our
myResult object to catch the data or status when the operation completes. We
can then use
myService (the reference to the remote service) to call methods on the
service, such as the sayHello( ) method.
The path passed to getService( ), as specified by myServicePath, does
not include a file extension for the remote service. Therefore, Flash
can access a remote service without knowing its implementation
details. One of the powerful aspects of Flash Remoting is that it makes
almost all server-side services accessible in a uniform manner. How-
ever, you cannot automatically detect which remote services are avail-
able. That is, you need to know the remote service methods you
intend to call. Flash Remoting has no mechanism in place to find
unknown remote services on the fly.
Save the Flash movie as HelloWorld.fla. Before the movie can be tested, we need to
create the server-side code that implements the sayHello( ) function, as described in
subsequent sections.
Example 1-1 utilizes the trace( ) command to display the data in the Output window
in the Flash authoring environment. Therefore, the output is visible only when the
movie is tested in the authoring environment and not when tested in a browser.
Seitenansicht 23
1 2 ... 19 20 21 22 23 24 25 26 27 28 29 ... 39 40

Kommentare zu diesen Handbüchern

Keine Kommentare