Flash CS3 Documentation |
|||
| 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);
Flash CS3
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000023.html
Comments
ASEVBill said on Dec 20, 2007 at 4:14 PM :