Hi,
I have had a couple questions and off line chats with some fellow component developers, some questions were raised about invalidation. Specifically,
invalidateProperties()
invalidateSize()
invalidateDisplayList()
I was about to answer the question in a comment but, thought I could put a little more effort into a post.
Ok, for those that like to read…
In my last article a decade or so ago I talked about commitProperties(). I also referred to it as a component’s state queue or something like that. Well it turns out that confused some people because they thought I was talking about the UIComponent.currentState property.
Realign,
commitProperties() is the back bone of the components model. There, how about that.
measure() is the back bone of a components dimensions and position.
updateDisplayList() is the back bone of a component’s look and feel.
This is where the invalidation methods come into play. The brain in a human is a wonderful thing, it lets us talk, classify, listen etc(our human properties). The brain also measures itself constantly while walking, jumping and laughing(our human measurements) The brain also gives us our identity through what we choose to wear, how we do our hair(human look and feel).
Stack all these weird analogies together and you have one crazy component called the human system. Yes, that’s right, we are a organic component, very abstractly.
Now back to invalidation. If you closed your eyes, took a snap shot of what you heard, what you see, how you feel, how big you fell and where you were, this would be your state. Imagine living in that snap shot state for infinity… haha Don’t think so, now take that same thought and apply it to a flex component.
Would you want your component to live in a state of unchanging indifference? Of course not!!!
Enter…
invalidateProperties()
invalidateSize()
invalidateDisplayList()
So we have the brain that takes messages from everything, every human interface possible(eyes, ears, mouth, nose, etc) and changes your internal state instantly to feel something else. Well, man, your brain just called an invalidation method it has stored within itself!
When you call an invalidation method, it allows time for all the other senses to link up and sync up. Can you smell 10 things at once, or does you smell happen linearly within 1 millisecond?
The same applies to Flex, life doesn’t just happen all at once and things definatly don’t change all at once. But, one thing is for sure, things change in groups.
So each invalidation method of Flex changes a part of it’s back bone to adjust to the new stimuli.
The invalidateThis() method is like breathing in and the commitSomething() is the breathing out. It also coincides with frame passes of the player to allow the player to use processor cycles efficiently(allows the player to take a breath).
If you want to change your component’s internal model state, call invalidateProperties(), flag it and catch the actual implementation of that model change in the component’s breathing out method of commitProperties().
If you want to change your component’s internal dimension state, call invalidateSize(), flag it and catch the actual implementation of that size change in the component’s breathing out method of measure().
If you want to change your component’s internal look and feel, call invalidateDisplayList(), flag it and catch the actual implementation of that look and feel in the component’s breathing out method of updateDisplayList().
These 6 methods ARE VITAL to any successful components that are to be considered ‘professional’.
Once you get the hang of this, you can start creating your own sub ecosystems within your own framework using more aggregate invalidation and validation.
Thats all folks, back to a secret AIR project I am finishing up for component developers that hate how default styles work in Flex.
Peace, Mike