The doLater() method queues a function to be called when the selected operation finishes. The doLater() method is useful if you have functions or dynamically created controls that rely on nonsequential operations such as web services. Rather than try to time the return of data from a web service call, you can use the doLater() method to ensure that the necessary data is available before continuing.
The doLater() method is from the mx.core.UIObject class. The doLater() method has the following signature:
doLater(obj:Object, func: String, args: Array):Void
The obj argument is the object that contains the function. The func argument is the function to call on the object. The args argument is an optional array of arguments you can pass to the function.
The following example uses a call to the doLater() method to ensure that the current operation is completed before the createNext() custom method is called:
<?xml version="1.0"> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns:local="*"creationComplete="doLater(this,'createNext')"> <mx:Script><![CDATA[ var creationOrder = ["box1","box2","box3"]; var creationIndex = 0;function createNext() {var nextObj = this[creationOrder[creationIndex++]];nextObj.addEventListener("childrenCreated", this);nextObj.createComponents();if (creationIndex < creationOrder.length) {nextObj.getChildAt(0).addEventListener("creationComplete", this);} }function handleEvent(e:Object):Void {if (e.type == "creationComplete") {doLater(this, "createNext");} else {super.handleEvent(e); } } ]]></mx:Script> <mx:VBox id="box1" width="200" height="200" creationPolicy="none"> <mx:DataGrid width="190" height="95"> ... // Add data provider here. </mx:DataGrid> </mx:VBox> <mx:VBox id="box2" width="200" height="200" creationPolicy="none"> <mx:DataGrid width="190" height="95"> ... // Add data provider here. </mx:DataGrid> </mx:VBox> <mx:VBox id="box3" width="200" height="200" creationPolicy="none"> <mx:DataGrid width="190" height="95"> ... // Add data provider here. </mx:DataGrid> </mx:VBox> </mx:Application>
Version 1.5
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000487.htm
Comments
ntsiii said on Feb 3, 2005 at 8:46 AM : danger42 said on Feb 3, 2005 at 8:51 AM :