564
Creating Interaction with ActionScript
This same
on()
event handler code produces a different result when attached to a movie clip
object rather than a button. When attached to a button object, statements made within an
on()
handler are applied to the timeline that contains the button, by default. However, when
attached to a movie clip object, statements made within an
on()
handler are applied to the
movie clip to which the
on()
handler is attached.
For example, the following
onPress()
handler code stops the timeline of the movie clip to
which the handler is attached, not the timeline that contains the movie clip:
// Attached to the myMovie_mc movie clip instance
myMovie_mc.onPress() {
stop();
};
The same conditions apply to
onClipEvent()
handlers attached to movie clip objects. For
example, the following code stops the timeline of the movie clip that bears the
onClipEvent()
handler when the clip first loads or appears on the Stage:
onClipEvent(load) {
stop();
}
Jumping to a different URL
To open a web page in a browser window, or to pass data to another application at a defined
URL, you can use the
getURL()
global function or the
MovieClip.getURL()
method. For
example, you can have a button that links to a new website, or you can send timeline variables
to a CGI script for processing in the same way as you would an HTML form. You can also
specify a target window, the same as you would when targeting a window with an HTML
anchor tag (
<a></a>
).
For example, the following code opens the macromedia.com home page in a blank browser
window when the user clicks the button instance named
homepage_btn
:
// Attach to frame
homepage_btn.onRelease = function () {
getURL("http://www.macromedia.com", "_blank");
};
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...