13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Cli<strong>en</strong>t system <strong>en</strong>vironm<strong>en</strong>t<br />

Cli<strong>en</strong>t system In programming terms, a cli<strong>en</strong>t is the part of an application (or whole application) that runs on an<br />

individual’s computer and is used by a single user. The cli<strong>en</strong>t system is the underlying operating system on the user’s<br />

computer.<br />

Using the System class<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

The System class contains methods and properties that allow you to interact with the user’s operating system and<br />

retrieve the curr<strong>en</strong>t memory usage of the runtime. The methods and properties of the System class also allow you to<br />

list<strong>en</strong> for imeComposition ev<strong>en</strong>ts, instruct the runtime to load external text files using the user’s curr<strong>en</strong>t code page or<br />

to load them as Unicode, or set the cont<strong>en</strong>ts of the user’s clipboard.<br />

Getting data about the user’s system at run time<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

By checking the System.totalMemory property, you can determine the amount of memory (in bytes) that the<br />

runtime is curr<strong>en</strong>tly using. This property allows you to monitor memory usage and optimize your applications based<br />

on how the memory level changes. For example, if a particular visual effect causes a large increase in memory usage,<br />

you may want to consider modifying the effect or eliminating it altogether.<br />

The System.ime property is a refer<strong>en</strong>ce to the curr<strong>en</strong>tly installed Input Method Editor (IME). This property allows<br />

you to list<strong>en</strong> for imeComposition ev<strong>en</strong>ts (flash.ev<strong>en</strong>ts.IMEEv<strong>en</strong>t.IME_COMPOSITION) by using the<br />

addEv<strong>en</strong>tList<strong>en</strong>er() method.<br />

The third property in the System class is useCodePage. Wh<strong>en</strong> useCodePage is set to true, the runtime uses the<br />

traditional code page of the operating system to load external text files. If you set this property to false, you tell the<br />

runtime to interpret the external file as Unicode.<br />

If you set System.useCodePage to true, remember that the traditional code page of the operating system must<br />

include the characters used in your external text file in order for the text to display. For example, if you load an external<br />

text file that contains Chinese characters, those characters cannot display on a system that uses the English Windows<br />

code page because that code page does not include Chinese characters.<br />

To <strong>en</strong>sure that users on all platforms can view the external text files that are used in your application, you should<br />

<strong>en</strong>code all external text files as Unicode and leave System.useCodePage set to false by default. This way, the runtime<br />

interprets the text as Unicode.<br />

Saving text to the clipboard<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

The System class includes a method called setClipboard() that allows the Flash runtime to set the cont<strong>en</strong>ts of the<br />

user’s clipboard with a specified string. For security reasons, there is no Security.getClipboard() method, since<br />

such a method could pot<strong>en</strong>tially allow malicious sites to access the data last copied to the user’s clipboard.<br />

The following code illustrates how an error message can be copied to the user’s clipboard wh<strong>en</strong> a security error occurs.<br />

The error message can be useful if the user wants to report a pot<strong>en</strong>tial bug with an application.<br />

Last updated 6/6/2012<br />

871

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!