Programming ActionScript 3.0 |
|
|
|
| Getting started with ActionScript > Working with objects > Events > Event-handling examples | |||
Here are a few more concrete examples of events to give you an idea of some of the common event elements and possible variations available when you write event-handling code:
playButton is the instance name of the button, and this is a special name meaning "the current object":
this.stop();
function playMovie(event:MouseEvent):void
{
this.play();
}
playButton.addEventListener(MouseEvent.CLICK, playMovie);
entryText is an input text field, and outputText is a dynamic text field:
function updateOutput(event:TextEvent):void
{
var pressedKey:String = event.text;
outputText.text = "You typed: " + pressedKey;
}
entryText.addEventListener(TextEvent.TEXT_INPUT, updateOutput);
linkButton is the instance name of the button:
function gotoAdobeSite(event:MouseEvent):void
{
var adobeURL:URLRequest = new URLRequest("http://www.adobe.com/");
navigateToURL(adobeURL);
}
linkButton.addEventListener(MouseEvent.CLICK, gotoAdobeSite);
|
|
|
|