ActionScript Events
| Inheritance | MovieClip > UIObject class > UIComponent class > DynamicButton class > DynamicRadioButton class |
Events inherited from the UIObject class
The following table lists the events the DynamicButton and DynamicRadioButton
classes inherit from the UIObject class.
| Event |
Description |
| UIObject.draw |
Broadcast when an object is about to draw its graphics. |
| UIObject.hide |
Broadcast when an object's state changes from visible to invisible. |
| UIObject.load |
Broadcast when subobjects are being created. |
| UIObject.move |
Broadcast when the object has moved. |
| UIObject.resize |
Broadcast when an object has been resized. |
| UIObject.reveal |
Broadcast when an object's state changes from invisible to visible. |
| UIObject.unload |
Broadcast when the subobjects are being unloaded. |
Events inherited from the UIComponent class
The following table lists the events the DynamicButton and DynamicRadioButton
classes inherit from the UIComponent class.
| Event |
Description |
| UIObject.focusIn |
Broadcast when an object receives focus. |
| UIObject.focusOut |
Broadcast when an object loses focus. |
| UIObject.keyDown |
Broadcast when a key is pressed. |
| UIObject.keyUp |
Broadcast when a key is released. |
Events unique to the DynamicButton class
The following table lists the event of the DynamicButton class.
Usage 1:
on(click) {
. . .
}
Usage 2:
listenerObject = new Object();
listenerObject.click = function(eventObject) {
. . .
}
DynamicButtonInstance.addEventListener("click", listenerObject);
Event; broadcast to all registered listeners when the mouse is clicked (pressed and released) over the dynamic button.
The first usage example uses an on() handler and must be attached directly to a Dynamic Button instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the dynamic button dynButton, sends "_level0.dynButton" to the Output panel:
on(click) {
trace(this);
}
The second usage example uses a dispatcher/listener event model. A component instance (DynamicButtonInstance) dispatches an event (in this case, click) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.
For more information, see «EventDispatcher class» in Macromedia Flash MX 2004 Using Components Help.
This example, written on a frame of the Timeline, sends a message to the Output panel when the instance dynamicButton is clicked. The first line of code creates a listener object called buttonListener. The second line defines a function for the click event on the listener object. Inside the function is a trace() statement that uses the event object (eventObj) that is automatically passed to the function to generate a message. The target property of an event object is the component that generated the event. You can access instance properties from the target property (in this example, the DynamicButton.label property is accessed). The last line calls EventDispatcher.addEventListener() from the dynamicButton instance and passes it the click event and the buttonListener object as parameters.
buttonListener = new Object();
buttonListener.click = function(eventObj) {
trace("The selected instance is " + eventObj.target.label);
}
dynamicButton.addEventListener("click", buttonListener);
The following code also sends a message to the Output panel when a dynamic button is clicked. The on() handler must be attached directly to a dynamic button instance.
on(click) {
trace("dynamic button was clicked");
}
Usage 1:
on(rollover) {
. . .
}
Usage 2:
listenerObject = new Object();
listenerObject.rollover = function(eventObject) {
. . .
}
DynamicButtonInstance.addEventListener("rollover", listenerObject);
Event; broadcast to all registered listeners when the mouse pointer rolls over the dynamic button.
The first usage example uses an on() handler and must be attached directly to a Dynamic Button instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the dynamic button dynButton, sends "_level0.dynButton" to the Output panel:
on(rollover) {
trace(this);
}
The second usage example uses a dispatcher/listener event model. A component instance (DynamicButtonInstance) dispatches an event (in this case, rollover) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.
For more information, see «EventDispatcher class» in Macromedia Flash MX 2004 Using Components Help.
This example, written on a frame of the Timeline, sends a message to the Output panel when the instance dynamicButton is rolled over. The first line of code creates a listener object called buttonListener. The second line defines a function for the rollover event on the listener object. Inside the function is a trace() statement that uses the event object (eventObj) that is automatically passed to the function to generate a message. The target property of an event object is the component that generated the event. You can access instance properties from the target property (in this example, the DynamicButton.label property is accessed). The last line calls EventDispatcher.addEventListener() from the dynamicButton instance and passes it the rollover event and the buttonListener object as parameters.
buttonListener = new Object();
buttonListener.rollover = function(eventObj) {
trace("The rolled over instance is " + eventObj.target.label);
}
dynamicButton.addEventListener("rollover", buttonListener);
The following code also sends a message to the Output panel when a dynamic button is rolled over. The on() handler must be attached directly to a dynamic button instance.
on(rollover) {
trace("dynamic button was rolled over");
}
Usage 1:
on(rollout) {
. . .
}
Usage 2:
listenerObject = new Object();
listenerObject.rollout = function(eventObject) {
. . .
}
DynamicButtonInstance.addEventListener("rollout", listenerObject);
Event; broadcast to all registered listeners when the mouse pointer rolls out of the dynamic button.
The first usage example uses an on() handler and must be attached directly to a Dynamic Button instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the dynamic button dynButton, sends "_level0.dynButton" to the Output panel:
on(rollout) {
trace(this);
}
The second usage example uses a dispatcher/listener event model. A component instance (DynamicButtonInstance) dispatches an event (in this case, rollout) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.
For more information, see "EventDispatcher class" in Macromedia Flash MX 2004 Using Components Help.
This example, written on a frame of the Timeline, sends a message to the Output panel when the instance dynamicButton is rolled out. The first line of code creates a listener object called buttonListener. The second line defines a function for the rollout event on the listener object. Inside the function is a trace() statement that uses the event object (eventObj) that is automatically passed to the function to generate a message. The target property of an event object is the component that generated the event. You can access instance properties from the target property (in this example, the DynamicButton.label property is accessed). The last line calls EventDispatcher.addEventListener() from the dynamicButton instance and passes it the rollout event and the buttonListener object as parameters.
buttonListener = new Object();
buttonListener.rollout = function(eventObj) {
trace("The rolled out instance is " + eventObj.target.label);
}
dynamicButton.addEventListener("rollout", buttonListener);
The following code also sends a message to the Output panel when a dynamic button is rolled out. The on() handler must be attached directly to a dynamic button instance.
on(rollout) {
trace("dynamic button was rolled out");
}
Events unique to the DynamicRadioButton class
The following table lists the event of the DynamicRadioButton class.
Usage 1:
on(click) {
. . .
}
Usage 2:
listenerObject = new Object();
listenerObject.click = function(eventObject) {
. . .
}
DynamicRadioButtonGroup.addEventListener("click", listenerObject);
Event; broadcast to all registered listeners when the mouse is clicked (pressed and released) over the dynamic radio button or if the dynamic radio button is selected by means of the arrow keys.
The first usage example uses an on() handler and must be attached directly to a Dynamic Radio Button instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the dynamic radio button dynRadioButton, sends "_level0.dynRadioButton" to the Output panel:
on(click) {
trace(this);
}
The second usage example uses a dispatcher/listener event model. A component instance (DynamicRadioButtonInstance) dispatches an event (in this case, click) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.
For more information, see «EventDispatcher class» in Macromedia Flash MX 2004 Using Components Help.
This example, written on a frame of the Timeline, sends a message to the Output panel when a dynamic radio button in menuGroup is clicked. The first line of code creates a listener object called menuListener. The second line defines a function for the click event on the listener object. Inside the function is a trace() statement that uses the event object (eventObj) that is automatically passed to the function to generate a message. The target property of an event object is the component that generated the event. You can access instance properties from the target property (in this example, the DynamicRadioButton.selection property is accessed). The last line calls EventDispatcher.addEventListener() from menuGroup and passes it the click event and the menuListener object as parameters.
menuListener = new Object();
menuListener.click = function(eventObj) {
trace("The selected instance is " + eventObj.target.selection);
}
menuGroup.addEventListener("click", menuListener);
The following code also sends a message to the Output panel when a dynamic radio button is clicked. The on() handler must be attached directly to a dynamic radio button instance.
on(click) {
trace("dynamic radio button was clicked");
}
Usage 1:
on(rollover) {
. . .
}
Usage 2:
listenerObject = new Object();
listenerObject.rollover = function(eventObject) {
. . .
}
DynamicRadioButtonInstance.addEventListener("rollover", listenerObject);
Event; broadcast to all registered listeners when the mouse pointer rolls over the dynamic radio button or if the dynamic radio button is selected by means of the arrow keys.
The first usage example uses an on() handler and must be attached directly to a Dynamic Radio Button instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the dynamic radio button dynRadioButton, sends "_level0.dynRadioButton" to the Output panel:
on(rollover) {
trace(this);
}
The second usage example uses a dispatcher/listener event model. A component instance (DynamicRadioButtonInstance) dispatches an event (in this case, rollover) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.
For more information, see "EventDispatcher class" in Macromedia Flash MX 2004 Using Components Help.
This example, written on a frame of the Timeline, sends a message to the Output panel when one of the dynamic radio buttons in the group is rolled over. The first line of code creates a listener object called menuListener. The second line defines a function for the rollover event on the listener object. Inside the function is a trace() statement that uses the event object (eventObj) that is automatically passed to the function to generate a message. The target property of an event object is the component that generated the event. You can access instance properties from the target property (in this example, the DynamicButton.label property is accessed). The last line calls EventDispatcher.addEventListener() from the component instance and passes it the rollover event and the menuListener object as parameters.
menuListener = new Object();
menuListener.rollover = function(eventObj) {
trace("The rolled over menu item is " + eventObj.target.label);
}
menuItem1.addEventListener("rollover", menuListener);
menuItem2.addEventListener("rollover", menuListener);
menuItem3.addEventListener("rollover", menuListener);
menuItem4.addEventListener("rollover", menuListener);
The following code also sends a message to the Output panel when a dynamic radio button is rolled over. The on() handler must be attached directly to a dynamic radio button instance.
on(rollover) {
trace("dynamic radio button was rolled over");
}
Usage 1:
on(rollout) {
. . .
}
Usage 2:
listenerObject = new Object();
listenerObject.rollout = function(eventObject) {
. . .
}
DynamicRadioButtonInstance.addEventListener("rollout", listenerObject);
Event; broadcast to all registered listeners when the mouse pointer rolls out of the dynamic radio button or if the dynamic radio button is deselected by means of the arrow keys.
The first usage example uses an on() handler and must be attached directly to a Dynamic Radio Button instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the dynamic radio button dynRadioButton, sends "_level0.dynRadioButton" to the Output panel:
on(rollout) {
trace(this);
}
The second usage example uses a dispatcher/listener event model. A component instance (DynamicRadioButtonInstance) dispatches an event (in this case, rollout) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.
For more information, see "EventDispatcher class" in Macromedia Flash MX 2004 Using Components Help.
This example, written on a frame of the Timeline, sends a message to the Output panel when one of the dynamic radio buttons in the group is rolled out. The first line of code creates a listener object called menuListener. The second line defines a function for the rollout event on the listener object. Inside the function is a trace() statement that uses the event object (eventObj) that is automatically passed to the function to generate a message. The target property of an event object is the component that generated the event. You can access instance properties from the target property (in this example, the DynamicButton.label property is accessed). The last line calls EventDispatcher.addEventListener() from the component instance and passes it the rollout event and the menuListener object as parameters.
menuListener = new Object();
menuListener.rollout = function(eventObj) {
trace("The rolled out menu item is " + eventObj.target.label);
}
menuItem1.addEventListener("rollout", menuListener);
menuItem2.addEventListener("rollout", menuListener);
menuItem3.addEventListener("rollout", menuListener);
menuItem4.addEventListener("rollout", menuListener);
The following code also sends a message to the Output panel when a dynamic radio button is rolled out. The on() handler must be attached directly to a dynamic radio button instance.
on(rollout) {
trace("dynamic radio button was rolled out");
}
|