User Guide
182 Chapter 6: Creating Interaction with ActionScript
The following code then loads addUser.cfm into a blank browser window and passes to the CFM
page
variables_mc.name and variables_mc.age in the POST header:
variables_mc.getURL("addUser.cfm", "_blank", "POST");
For more information, see getURL() in Flash ActionScript Language Reference.
Creating interactivity and visual effects
To create interactivity and other visual effects, you need to understand the following techniques:
• “Creating a custom mouse pointer” on page 182
• “Getting the pointer position” on page 183
• “Capturing keypresses” on page 184
• “Setting color values” on page 187
• “Creating sound controls” on page 189
• “Detecting collisions” on page 192
• “Creating a simple line drawing tool” on page 194
Creating a custom mouse pointer
A standard mouse pointer is the operating system’s onscreen representation of the position of the
user’s mouse. By replacing the standard pointer with one you design in Flash, you can integrate
the user’s mouse movement within the SWF file more closely. The sample in this section uses a
custom pointer that looks like a large arrow. The power of this feature, however, is your ability to
make the custom pointer look like anything—for example, a football to be carried to the goal line
or a swatch of fabric pulled over a chair to change its color.
To create a custom pointer, you design the pointer movie clip on the Stage. Then, in
ActionScript, you hide the standard pointer and track its movement. To hide the standard
pointer, you use the
Mouse.hide() method of the built-in Mouse class.
To create a custom pointer:
1.
Create a movie clip to use as a custom pointer, and place an instance of the clip on the Stage.
2.
Select the movie clip instance on the Stage.
3.
In the Property inspector, type cursor_mc into the instance name text box.
4.
Select Window > Development Panels > Actions to open the Actions panel if it is not
already visible.
5.
Type the following code in the Actions panel:
Mouse.hide();
cursor_mc.onMouseMove = function() {
this._x = _xmouse;
this._y = _ymouse;
updateAfterEvent();
};