Internet / Software Applications

Macromedia Flash MX 2004 ActionScript Programming Tutorial

Sending Variables Out of Flash

Several actions in ActionScript let you send variables from a Flash movie to a server-side script. Some let you receive a response back from the server and some don’t. Later in the tutorial, we describe how to do the former when we show you how to create a functioning form for use with a server-side script. For the latter, you can use the getURL() action, which sends name/value pairs to a URL:

getURL(URL, window, method);

URL is the web site address; window specifies the browser window to load (“_blank”, “_self”, “_parent”, or “_top”); and method specifies the GET or POST method.

For example, you can use the getURL() action to send an e-mail from the Flash movie when the user clicks a button:

on(release) {

var email = “techsupport@mysite.com”;

var subject = escape(“Download Problems”);

var body = “Help”;

getURL(“mailto:”+email+”&subject=”+subject+”&body=”+body);

}

This code opens a new message in the user’s default e-mail program with the e-mail address, subject and body filled in with the contents of the variables.

Macromedia Flash MX 2004 ActionScript 2.0 Tutorial and Free Online Training Course

In this section, you learned about:

  • Declarations and Scope
  • Data Types
  • Expressions
  • Loading external variables
  • Sending variables out of Flash