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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

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

var url:String = "log_visitor.cfm";<br />

var request:URLRequest = new URLRequest(url);<br />

request.method = URLRequestMethod.POST;<br />

request.data = new URLVariables(Capabilities.serverString);<br />

var loader:URLLoader = new URLLoader(request);<br />

Capabilities example: Detecting system capabilities<br />

Flash Player 9 and later<br />

The CapabilitiesExplorer example demonstrates how you can use the flash.system.Capabilities class to determine<br />

which features the user’s version of the Flash runtime supports. This example teaches the following techniques:<br />

Detecting which capabilities the user’s version of the Flash runtime supports using the Capabilities class<br />

Using the ExternalInterface class to detect which browser settings the user’s browser supports<br />

To get the application files for this sample, see www.adobe.com/go/learn_programmingAS3samples_flash. The<br />

CapabilitiesExplorer application files can be found in the folder Samples/CapabilitiesExplorer. This application<br />

consists of the following files:<br />

File Description<br />

CapabilitiesExplorer.fla<br />

or<br />

CapabilitiesExplorer.mxml<br />

CapabilitiesExplorer overview<br />

Flash Player 9 and later<br />

The CapabilitiesExplorer.mxml file is responsible for setting up the user interface for the CapabilitiesExplorer<br />

application. The capabilities of the user’s version of the Flash runtime will be displayed within a DataGrid compon<strong>en</strong>t<br />

instance on the Stage. Their browser capabilities will also be displayed if they are running the application from an<br />

HTML container and if the external API is available.<br />

Wh<strong>en</strong> the main application file’s creationComplete ev<strong>en</strong>t is dispatched, the initApp() method is invoked. The<br />

initApp() method calls the getCapabilities() method from within the<br />

com.example.programmingas3.capabilities.CapabilitiesGrabber class. The code for the initApp() method is as<br />

follows:<br />

private function initApp():void<br />

{<br />

var dp:Array = CapabilitiesGrabber.getCapabilities();<br />

capabilitiesGrid.dataProvider = dp;<br />

}<br />

Last updated 6/6/2012<br />

The main application file in Flash (FLA) or Flex (MXML).<br />

com/example/programmingas3/capabilities/CapabilitiesGrabber.as The class that provides the main functionality of the application,<br />

including adding the system Capabilities to an array, sorting the<br />

items, and using the ExternalInterface class to retrieve browser<br />

capabilities.<br />

capabilities.html An HTML container that contains the necessary JavaScript to<br />

communicate with the external API.<br />

873

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

Saved successfully!

Ooh no, something went wrong!