View comments | RSS feed

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.

See also

EventDispatcher.addEventListener()


Comments


iszzz said on Aug 23, 2004 at 8:17 AM :
This Delegate.create() works great, except how do you remove the eventListener when you code the Delegate.create into addEvenListener argument?

removeEventListener doesn't seem to be working here???
MM tech writer said on Aug 23, 2004 at 11:16 AM :
The following is excerpted from a DevNet article:
http://www.macromedia.com/devnet/mx/flash/articles/eventproxy.html

-----------------------
If you need to remove the listener at a later point, then you must change the code to store a reference to the delegate, as follows:

import mx.utils.Delegate;
var dataGridDelegate:Function = Delegate.create(this,onMyDataGridChange);
myDataGrid.addEventListener("change", dataGridDelegate);
function onMyDataGridChange(eventObj:Object):Void
{
trace("myDataGrid change event fired");
}


Then, you can remove the listener with this code:

myDataGrid.removeEventListener("change", dataGridDelegate);

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00002401.html