Hi Mike,
I was thinking that when designing a custom layout class, you could do
the following that would allow you to tie layout states to custom view
states in a custom component:
1) What are "layout states"? When you first outline/design your
layout (all the math and how things are position, etc.), you'd start
by saying "what are the different states the objects in this layout
might have?"
- In the CoverFlowLayout, just thinking off the top of my head,
an item in the coverflow can be "selected", "unselected", and maybe
you could even add "hidden" or "last" if you wanted to change the way
coverflow items looked x many items past the selected one.
2) Now that you have the "layout states", you create simple variables
for them in the CoverFlowLayout class:
selectedState:String; // (haven't thought of the best way to do this
yet, maybe just strings, maybe booleans, maybe the binding tag?
3) In your CustomComponent.mxml class, say you have
"myImageDetailsState" and "myImageThumbState". You could, in the
CoverFlowLayout tag of an OpenFlux List, do something like this to
assign your state names to the layout state names:
<CoverFlowLayout mapToStates="{selectedState:"myImageDetailsState",
unselectedState:"myImageThumbState"}"/>
4) Then in the update() or adjust() method (wherever the animation
logic goes), you could set the "child" component to that whatever
state it is in in the layout, which would automatically be tied into
your component's state.
- This would make it so that when a coverflow item was selected,
the "selectedState" variable would be assigned to the selectedIndex
component. Flex 4 does something like this with skins, in the
commitProperties method of FxComponent:
if (skinStateIsDirty)
(
skin.currentState = getCurrentSkinState();
skinStateIsDirty = false;
)
I was thinking you could do a similar thing for layouts. This if-loop
in the adjust() method for CoverFlowLayout might look like this:
if(i < selectedIndex) {
token.x *= -1;
token.rotationY *= -1;
child.currentState = unselectedState; // change the state of all non-
selected layout items to display a small image...
} else if(i == selectedIndex) {
token.x = 0;
token.z = -200 / 2;
token.rotationY = 0;
offset = 0;
child.currentState = selectedState; // selected item shows extra text
fields and some buttons...
}
4) So you have these generic "states for the layout" variables that
can be assigned to any state in your component. This is nice so you
don't have to call your component's state "selectedState", you can
call it "myImageDetailsState" or whatever and assign it to the
"selectedState" variable of the CoverFlowLayout.
For other layouts, like the ProductCatalogPanel and its hardwired
layout in FlexStore for instance, they switch between 1, 2, 3, and 4
columns, making the Thumbnail view display different elements in
each. So in a DynamicColumnLayout, you could have the
"oneColumnState", "twoColumnState", etc. Then you just assign your
component's states to those and it takes care of everything for you!
It just seems like it would give you some more control over the layout
which would be nice.
Hope that helps!
Best,
Lance
> Teoti Graphix Bloghttp://
www.blog.teotigraphix.com
>
> You can find more by solving the problem then by 'asking the question'.- Hide quoted text -
>
> - Show quoted text -