Home >
New Poll: How do you handle your Flash objects?
This week's poll was brought to us by Amy Blankenship.
The Flex Framework supplies a component life-cycle that allows (or forces, depending on your perspective) Flex developers to defer the work necessary to respond to changing styles and properties until a later time, which allows the work necessary based on multiple changes to be consolidated into one place. For instance, if you have a Label component and change its text, font size, and font weight, all of those will result in a change of the size of the label. So it is more efficient to find a way to defer the final changes in size until after we're sure that all of the changes that are to be made in a given cycle have been made. The way this is handled in Flex is that changes to properties and styles that affect the properties of subcomponents will call invalidateProperties(), those that affect the way subcomponents are laid out will call invalidateDisplayList(), and those that affect the size of the component will call invalidateSize(). Calls to these methods will in turn trigger a later call to commitProperties(), updateDisplayList() and measure().
I find that when I work in Flash, I often need to build functionality that waits to perform changes until all information is known, so I sometimes build in my own version of the Flex component life cycle. Flash has a similar pattern in its Component, but the methods are different. If you're a Flash developer, how do you handle implementing the changes needed based on changes in the custom properties of your Flash objects?




Facebook Application Development
I have an interface IInvalidatingDisplayObject with invalidate() and validate() calls. Validation happens automatically with an ICallLaterManager, which queues calls until the next EXIT_FRAME event. My default implementation is InvalidatingSprite, which generally sets up everything I need automatically. It has a draw() method that gets called from validate that I can override and customize. Generally, this is lighter than a full component architecture, but I can extend it, if I need a bit more, such as a separation of properties/measurement/drawing like Flex.
Sometimes I just extend fl.core.UIComponent and use what's already available. Usually, that's only if I'm using fl.* components elsewhere in my application.
Whenj deving without the Flash Framework I extend the UIComponent class is Flash which as you mentioned has its own invalidation system built in, for display, data etc.
It's there, ready to use, so why rebuild it.
Its really a tough task when we don't know much about it......Thanks for sharing such good and informative suggestions.
Mio Navman Spirit S500T