There are some limitations when using web services with a SWF file, including the following:
•
Flash does not support web services with more than one defined port when using the
WebServiceConnector component.
•
Flash does not support web services with more than one defined service when using the
WebServiceConnector component.
•
Flash does not support non-HTTP web services.
•
Flash does not support web services on non-SOAP ports.
•
Flash does not support REST web services.
•
Flash does not support the
Note: If you are using the WebServiceConnector component in Flash MX Professional, you must
place the component instance in Scene 1.
For more information about using complex data with your web service, see
www.macromedia.com/support/flash/ts/documents/webserviceflaws.htm.
Adding data validation and loading
Try to validate any information you retrieve before you send that data to a server. This reduces
strain on the remote server, because it does not handle as many requests when users do not fill in
required fields. You should never solely rely on client-side validation in any application, so there
must also be server-side validation.
Even if you build a simple registration or login form, check that the user has entered their name
and password. Perform this validation before sending the request to the remote server-side script
and waiting for a result. Do not rely only on server-side validation. If a user enters only a
username, the server-side script has to receive the request, validate the data being sent, and return
an error message to the Flash application, stating that it requires both the username and password.
Likewise, if validation is performed only on the client side (within the SWF file), it might be
possible for a user to hack the SWF file and manage to bypass the validation, and send data to
your server in an attempt to post the bad data.
Client-side validation can be as simple as making sure that a form field has a length of at least one
character, or that the user entered a numeric value and not a string. If you try to validate an e-mail
address, for example, check that the text field in Flash isn't empty and contains at least the at sign
(
) and dot (
) characters. For the server-side validation, add more complex validation and check
@
.
that the e-mail address belongs to a valid domain.
You must create ActionScript to handle the data that loads into the SWF file from the server.
After you finish loading data into a SWF file, the data can be accessed from that location. It's
important to use ActionScript to check whether the data has been fully loaded. You can use
callback functions to send a signal that the data has been loaded into the document.
When you load data, it can be formatted in several ways. You might load XML, and in this case,
you must use the XML class methods and properties to parse the data and use it. If you use
name/value pairs, the pairs turn into variables and you can manipulate them as variables.
124
Chapter 3: Using Best Practices
tag.
import
Need help?
Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?
Questions and answers