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

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 40
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 15
This is the Title of the Book, eMatter Edition
Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
14
|
Chapter 1: Introduction to Flash Remoting
This example queries a database and outputs the results as a table in the browser.
This type of mixture of HTML and server-side code is commonplace in web applica-
tion development. Notice, however, that the presentation of the content is created
entirely by the application server. The HTML table doesn’t exist until the query is
executed and the results are sent to the browser.
Using Flash Remoting, the application server code is utilized for the logic only—que-
rying the database. The results of the query are returned to the Flash movie without
any further parsing or manipulating. Using Flash Remoting, a ColdFusion compo-
nent could be written as follows:
<cfcomponent displayName="searchBooks">
<cffunction name="getTitles" returnType="query" access="remote">
<cfargument name="search" type="string" default="%" />
<cfquery name="rsGetSearchResults" datasource="bookstore">
SELECT Title, Category, Pub_No FROM Books
WHERE Title LIKE '%#form.searchfield#%'
</cfquery>
<cfreturn rsGetSearchResults />
</cffunction>
</cfcomponent>
Notice the line in bold, <cfreturn rsGetSearchResults />, which returns the entire
recordset to the Flash movie as an ActionScript RecordSet object. The Flash movie, in
turn, can use the recordset without any further parsing. For example, to attach the
recordset to a DataGrid component in Flash, you can simply use this result handler
in ActionScript:
function rsGetSearchResults_Result (result_rs) {
myGridComponent.setDataProvider(result_rs);
}
Again, the Flash movie is working with the recordset as it comes from the server. No
further parsing is necessary. Also, the ActionScript programmer has at his disposal a
series of highly complex and interactive interface elements, unlike HTML forms,
which are limited in functionality.
Another advantage is that the Flash movie looks the same in all browsers. The
HTML language is ubiquitous, but the implementation is not uniform. Typically,
you have to rely on CSS implementation, JavaScript being enabled, and/or cookies
being enabled, or you have to create even more client-side code to handle the many
possible user configurations.
Session Management in Flash
HTTP is a stateless protocol. The web server treats each page request coming from a
browser as coming from an entirely new user. To create the illusion of maintaining
state, many application servers have state management (or session management)in
place to create a seamless experience for the end user. Session management is a bit of
Seitenansicht 15
1 2 ... 11 12 13 14 15 16 17 18 19 20 21 ... 39 40

Kommentare zu diesen Handbüchern

Keine Kommentare