Reputation: 1107
I have a function that is made up of two main parts (I'll call them A and B). Part B needs to run when part A is fully done with its layout changes. However, there is no "part A is done" signal, and thus I've been calling a validateNow() before part B runs. This works but seems awfully inefficient - was wondering if there are any other tricks to force an immediate measure or something along those lines or if I'm stuck. thank you!
Upvotes: 1
Views: 417
Reputation: 14221
You can invoke part B from within updateDisplayList()
.
For that you need to introduce some flag:
private var partAPerformed:Boolean;
Then within function after finishing part A:
partAPerformed = true;
invalidateDisplayList();
And then:
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (partAPerformed)
{
// Part B
partAPerformed = false;
}
}
Upvotes: 2
Reputation: 5577
Some code would be helpful because I'm having difficulty picturing the situation you are describing. I mean, I'm guessing the operations going on are asynchronous, because obviously anything synchronous would make timing a non-issue. What exactly is part A doing?
In the meantime however you should always think of asynchronous operations in terms of events and event listeners. So have two functions with one listening for an event dispatched by operations in the other, rather than trying to make one function that handles everything.
Upvotes: 1