explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

Note to Self: Spark States

2 Comments

When creating a subclass of the Spark ItemRenderer and using states.  The default state should be named “default” rather than “normal”.  Initially I had used “normal” and found that state logic was breaking down when setting the currentState via a ClassFactory’s property definition.  I believe the “normal” name is a carry over from borrowed state names in the ButtonSkin classes.

So use:

<s:State name="default"/>

Instead of:

<s:State name="normal"/>

…. unless for some reason you are extending a SparkSkin and see an explicitly defined state with the name “normal”.

Advertisements

2 thoughts on “Note to Self: Spark States

  1. Doesn’t really make sense. ItemRenderers have builtin states, and the default (up state) is “normal”. Defining a state named “default” is creating a bran new state which is probably no different than the “normal” state… and possibly introducing more unexpected behavoir.

    The “normal” state has nothing to do with ButtonSkin classes. Take a look at the getCurrentRendererState() method in ItemRenderer.

    You didn’t mention the specifics of the problem you were having with the “normal” state, so I can’t help you there. All I can say is utilizing the “normal” skin state is the documented and intended way to use ItemRenderers.

    • Basically I had 4 different states on the itemRenderer. They addressed the normal, selected, selected & active, and open states. I purposely named those to present the intended user experience rather than the actual state names.

      On the list component I was using, I had set the itemRendererFunction, based on various conditions, I then would set the currentState on the ClassFactory that I returned from the above function.

      Anytime I defined a state named “normal”, despite having their currentStates set, the item renderers would only display the normal state, ignoring any other states being requested. However if I renamed that state to “default” all worked as expected.

      I may be using the states and the itemRendererFunction incorrectly. I am WAY behind the Spark game as I was on a Flex 3 project for that last 1.5 years. Any tips and hints are appreciated.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s