changing children of dynamic created states
I'm building an Xml-driven application. I create new states in a seperate actionscript-class. These states all contain a DataGrid. I can switch the s开发者_运维百科tates in the Main.mxml.
But now I would like to access certain children of the DataGrid. In this case I would like to toggle the visibility of GridItems, from a Button in the Main.mxml.
How do I have access and apply this to the already created states ? I tried to create RemoveChilds and override/push it to the state. All I archieved was to remove an entire GridRow at the very last state, but it should be just one GridItem at every state.
Thanks a lot for help!
Reverse your problem. Don't try push the information into the states, have the states fetch the information when needed.
Add a binding in each state to check the status of the button and do the removeChild logic itself.
Ok, I definitively have to try your suggestions. I worked it out in my way, but rather complicated I guess: I push every GridItem in an array when the states are created and create a getFunction which returns the array and so the Main.mxml can access it. The toggler-function in the Main.mxml looks like this:
_gridItemArray = theStateClass.getGridItemArray();
if(_buttonToggler == false)
{
for each(_gridItemArray.child in _gridItemArray)
{
_gridItemArray.child.visible = false;
}
_buttonToggler = true;
}
else
{
for each(_gridItemArray.child in _gridItemArray)
{
_gridItemArray.child.visible = true;
}
_buttonToggler = false;
}
精彩评论