getURL()

Availability

Flash Lite 1.0.

Usage

getURL(url [ , window [, "variables"]])

Operands

url
The URL from which to obtain the document.

window
An optional parameter that specifies the window or HTML frame that the document should load into.
Note: The window parameter is not specified for Flash Lite applications, because browsers on cell phones do not support multiple windows.

You can enter an empty string, or the name of a specific window, or choose from the following reserved target names:

  • _self specifies the current frame in the current window.

  • _blank specifies a new window.

  • _parent specifies the parent of the current frame.

  • _top specifies the top-level frame in the current window.

variables
A GET or POST method for sending variables. If there are no variables, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for sending long strings of variables.

Description

Function; loads a document from a specific URL into a window or passes variables to another application at a defined URL. To test this function, make sure the file you want to load is in the specified location. To use an absolute URL (for example, http://www.myserver.com), you need a network connection.

Flash Lite 1.0 recognizes only the HTTP, HTTPS, mailto, and tel protocols. Flash Lite 1.1 recognizes these protocols, and in addition, the file, SMS (short message service), and MMS (multimedia message service) protocols.

Flash Lite passes the call to the operating system, and the operating system handles the call with the registered default application for the specified protocol.

Only one getURL() function is processed per frame or per event handler.

Certain handsets restrict the getURL() function to key events only, in which case the getURL() call is processed only if it is triggered in a key event handler. Even under such circumstances, only one getURL() function is processed per event handler.

Example

In the following ActionScript, the Flash Lite player opens mobile.example.com in the default browser:

myURL = "http://mobile.example.com"; 
    on(keyPress "1") { 
    getURL(myURL); 
}

You can also use GET or POST for sending variables from the current timeline. The following example uses the GET method to append variables to a URL:

firstName = "Gus"; 
lastName = "Richardson"; 
age = 92; 
getURL("http://www.example.com", "_blank", "GET");

The following ActionScript uses POST to send variables in an HTTP header:

firstName = "Gus"; 
lastName = "Richardson"; 
age = 92; 
getURL("http://www.example.com", "POST");

You can assign a button function to open an e-mail composition window with the address, subject, and body text fields already populated. Use one of the following methods to assign a button function: Method 1 for either Shift-JIS or English character encoding; Method 2 only for English character encoding.

Method 1: Set variables for each of the desired parameters, as in this example:

on (release, keyPress "#"){ 
subject = "email subject"; 
body = "email body"; 
getURL("mailto:somebody@anywhere.com", "", "GET"); 
}

Method 2: Define each parameter within the getURL() function, as in this example:

on (release, keyPress "#"){ 
getURL("mailto:somebody@anywhere.com?cc=cc@anywhere.com&bcc=bcc@anywhere. 
com&subject=I am the email subject&body=I am the email body"); 
}

Method 1 results in automatic URL encoding, while Method 2 preserves the spaces in the strings. For example, the strings that result from using Method 1 are as follows:

email+subject 
email+body

In contrast, Method 2 results in the following strings:

email subject 
email body

The following example uses the tel protocol:

on (release, keyPress "#"){ 
    getURL("tel:117"); 
}

In the following example, getURL() is used to send an SMS message:

mySMS = "sms:4156095555?body=sample sms message"; 
on(keyPress "5") { 
    getURL(mySMS); 
}

In the following example, getURL() is used to send an MMS message:

// mms example 
myMMS = "mms:4156095555?body=sample mms message"; 
on(keyPress "6") { 
    getURL(myMMS); 
}

In the following example, getURL() is used to open a text file stored on the local file system:

// file protocol example 
filePath = "file://c:/documents/flash/myApp/myvariables.txt"; 
on(keyPress "7") { 
    getURL(filePath); 
}