View comments | RSS feed

UIObject.doLater()

Availability

Flash Player 6 (6.0 79.0).

Edition

Flash MX 2004.

Usage

componentInstance.doLater(target, "function")

Parameters

target A reference to a Timeline that contains the specified function.

function A string indicating a function name to be called after a frame has passed.

Returns

Nothing.

Description

Method; calls a user-defined function only after the component has finished setting all of its properties from the Property inspector or Component inspector. All version 2 components that inherit from UIObject have the doLater() method.

Component properties set in the Property inspector or Component inspector may not be immediately available to ActionScript in the Timeline. For example, attempting to trace the label property from a CheckBox component using ActionScript on the first frame of your SWF fails without notification, even though the component appears on the Stage as expected.

Although properties that are set in a class or a frame script are available immediately, most properties assigned in the Property inspector or Component inspector are not set until the next frame within the component itself.

Although any approach that delays access of the property will resolve this problem, the simplest and most direct solution is to use the doLater() method.

Example

The following example shows how the doLater() method is used:

// doLater() is called from the component instance

myCheckBox.doLater (this, "delay");

// the function or method called from doLater()

function delay() {
  trace(myCheckBox.label); // the property can now be traced
  // any additional statements go here
}

Comments


rghome said on Oct 30, 2004 at 3:47 AM :
If doLater is called twice with the same function, will that function be called twice ?
jepo said on Nov 8, 2004 at 2:04 PM :
If I'm understanding correctly, I believe it is. I tried this code:

// doLater() is called from the component instance
myCheckBox.doLater(this, "delay");
myCheckBox.doLater(this, "delay");

// the function or method called from doLater()
function delay() {
trace(myCheckBox.label);
// the property can now be traced
// any additional statements go here
}

And it appears to be called twice.
ColemanTO said on Apr 6, 2005 at 12:44 PM :
The statement "A string indicating a function name to be called after a frame has passed." is a little ambiguous. Which frame? The current frame? Any frame? Any timeline?

 

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/00002935.html