User Guide

388 Chapter 6: Components Dictionary
Delegate class
Inheritance Object > Delegate
ActionScript Class Name mx.utils.Delegate
The Delegate class lets you run a function in a specific scope. This class is provided so that you
can dispatch the same event to two different functions (see “Delegating events to functions
on page 63), and so that you can call functions within the scope of the containing class.
When you pass a function as a parameter to
EventDispatcher.addEventListener(), the
function is invoked in the scope of the broadcaster component instance, not the object in which it
is declared (see “Delegating the scope of a function” on page 65). You can call
Delegate.create() to call the function within the scope of the declaring object.
Method summary for the Delegate class
The following table lists the method of the Delegate class.
Delegate.create()
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX Professional 2004.
Usage
Delegate.create(scopeObject, function)
Parameters
scopeObject
A reference to an object. This is the scope in which to run the function.
function A reference to a function.
Description
Method (static); allows you to delegate events to specific scopes and functions. Use the following
syntax:
import mx.utils.Delegate;
compInstance.addEventListener("eventName", Delegate.create(scopeObject,
function));
The scopeObject parameter specifies the scope in which the specified function is called.
Example
For examples of Delegate.create(), see “Delegating events” on page 63.
Property Description
Delegate.create() A static method that allows you to run a function in a specific scope.
CHAPTER 6
Components Dictionary