Give us a call 203-379-0773

How do you tell if a component is in a transition?

I'm working on Fleshing out the Flextras CalendarDisplay component. I think I'm finally happy with our approach to implementing a day view. One of the things we want to support is the ability to transition between a month view, a week view, and a day view.

Transitioning from a day display to a month display was working fine. Transitioning from the month to the day was not. After stepping through the code I discovered that the updateDisplayList() method would resize the day before the effect ran, thus negating the effect.

I needed a way to figure out if a transition was playing and tell the component not to run the updateDisplayList() method.

I've seen some situations where you set a Boolean value "transitionRunning" to true before running the play method, then set it back to false in a listener to the effectEnd method.

But, that wouldn't work in this situation. If the transition is a transition between two states, then all the code for starting / stopping the effects is locked up in private methods of UIComponent.

I ended up writing this method to loop over the transitions array and figure out if one of the effects was playing.

protected function isTransitionPlaying():Boolean{
if(this.transitions){
for each(var transition : Transition in this.transitions){
if(transition.effect.isPlaying){
return true;
}
}
}
return false;
}

My intuition tells me there should be an easier way, but I'm not sure what that is.

Update:

A friend on twitter recommended I take a look at the activeEffects property. The function would be modified like this:

protected function isTransitionPlaying():Boolean{
if(this.activeEffects.length >
0){
return true;
}
return false;
}

Unfortunately, that didn't work. Even though a transition was running, it was not on the activeEffects array. I'm unsure why.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Ian McLean's Gravatar If you add an effect to a effect event on a component that effect will show in the activeEffects array when running.

<mx:Blur id="blurEffect" />
<mx:Box addEffect="blurEffect" />

On the other hand, if you manually target and play

<mx:Blur id="blurEffect" target="box"/>

<mx:Box id="box">
<mx:Button creationComplete="blurEffect.play()" />
</mx:Box>

It will not show up in activeEffects :)
# Posted By Ian McLean | 12/24/09 12:46 AM