
Application Development Tips and Tricks 57
Writing double-byte applications
If you are using server-side ActionScript in a development environment or language kit that
facilitates double-byte text (such as an Asian language character set), your server-side ActionScript
must be in an ASC file that has been UTF-8-encoded. This means you’ll need a JavaScript editor,
such as Macromedia Dreamweaver MX, that UTF-8-encodes files. (Simple text editors, such as
Microsoft Windows Notepad, don’t UTF-8-encode files.) Then, you can use built-in JavaScript
methods such as
Date.toLocaleString, which converts the string to the locale encoding for that
system.
To ensure UTF-8 encoding, in Dreamweaver MX, you’ll need to change two settings: the
document encoding setting and the inline input setting.
• To change the document encoding setting, select Modify > Page Properties, then select
Document Encoding. Choose Other to create a document with the encoding your operating
system is using.
• To change the inline input setting, choose Edit > Preferences or Dreamweaver > Preferences
(Mac OS X), and then click General. Select Enable Double-Byte Online Input to enable to
enter double-byte text.
To use double-byte characters as method names, the method names must be assigned using the
object array operator and not the dot operator:
// This is the CORRECT way to create double-byte method names
obj["Any_hi_byte_name"] = function(){}
// This is the INCORRECT way to create double-byte method names
obj.Any_hi_byte_name = function() {}
Unloading and reloading applications
Application instances are normally unloaded because of garbage collection. The first time the
garbage collector runs after all clients have disconnected from an application, the application will
be unloaded. In other words, applications aren’t unloaded immediately when all clients
disconnect. Since application startup usually takes some time, it is better for the application to
stay open for a little while, so that the next client that connects doesn’t incur the startup cost.
By default, garbage collection happens once every 20 minutes (every 5 minutes for unused I/O
threads). You can configure these values to be any number of minutes (greater than zero); for
more information, see Managing Flash Communication Server.
Also, whenever you make changes to the main.asc file, you must reload the application for the
changes to be applied. This will disconnect all users currently connected to the application. You
can do this either through the Administration Console (see Managing Flash Communication
Server) or the Communication App inspector (see “Using the Communication App inspector” on
page 97).
Implementing dynamic access control
Server-side ActionScript provides a mechanism to implement dynamic access control list (ACL)
functionality for shared objects and streams. By default, all connections have full access to all
streams and shared objects. You can control who has access to create, read, or update shared
objects or streams. Every connection to a server-side application instance is represented by a
Client object on the server-side, and each Client object has two properties:
readAccess and
writeAccess. Using these two properties, you can control access on a per-connection basis.
Commentaires sur ces manuels