Macromedia flash 8-learning flash lite 1.x actionscript User Manual

Page of 26
20
Common Scripting Tasks
Typically, you use capability variables to determine if a device supports a specific feature 
before attempting to use that feature. For example, suppose that you wanted to develop an 
application that downloads data from a web server using the 
loadVariables()
 function. 
Before attempting to load the data, you can first check the value of the 
_capLoadData
 
variable to determine if the device supports that feature, as follows:
if(_capLoadData == 1) {
loadVariables("http://www.macromedia.com/data.txt");
} else {
status_message = "Sorry, unable to load external data."
}
Flash Lite defines capability variables on the root timeline of the main SWF file. So to access 
these variables from another timeline—for example, from within a movie clip’s timeline—you 
need to qualify the path to the variable. For instance, the following example uses a slash (
/
) to 
provide the fully qualified path to the 
_capSMS
 variable. 
canSendSMS = /:_capSMS
Opening a web page
You use the 
getURL()
 command to open a web page in the device’s web browser. This is the 
same way you open a web page from a desktop Flash application. For example, the following 
opens the Macromedia web page:
getURL("http:www.macromedia.com");
Flash Lite processes only one 
getURL()
 action per frame or per event handler. Certain 
handsets restrict the 
getURL()
 action to keypress events only, in which case the 
getURL()
 call 
is processed only if it is triggered within a keypress event handler. Even under such 
circumstances, only one 
getURL()
 action is processed per keypress event handler. The 
following code, attached to a button instance on the Stage, opens a web page when the user 
presses the Select button on the device: 
on (keyPress "<Enter>"){
getURL("http://www.macromedia.com");
}
Initiating a phone call
To initiate a phone call from a Flash Lite application, you use the 
getURL()
 function. 
Typically, you use this function to open a web page, but in this case you specify 
tel:
 as the 
protocol (in place of 
http)
, and then provide the phone number you wish the phone to dial. 
When you call this function, Flash Lite displays a confirmation dialog box asking the user for 
permission to make the call to the specified number.