Here's here's one way I might do this:
public function setViewState(state:String):void
{
//Sets parent's view state
this.currentState = state;
// The parent is responsible for controlling its child
// component view states. All components must implement
// IView's setViewState() and all components must define
// view states that match their parents' view states.
// That way, all child components will be updated based
// on the parent's view state.
// I only go down to grandchildren because that's typically
// as deep as I'll make the child component heirarchy.
// But...you never know. So... TODO: Make recursive.
var children:Array=this.getChildren();
for (var i:String in children)
{
if (children[i].hasOwnProperty("setViewState"))
children[i].setViewState(this.currentState);
else {
Alert.show(children[i].toString());
var grandchildren:Array = Container(children
[i]).getChildren();
for (var j:String in grandchildren)
{
if (grandchildren[j].hasOwnProperty
("setViewState"))
grandchildren[j].setViewState
(this.currentState);
}
}
}
}
It needs to be recursive, but maybe there's a better way?
Bruce
--- In [email protected], "Bruce Denham" <[EMAIL PROTECTED]>
wrote:
>
> I have a parent component with various view states defined. Each
child
> component of the parent defines the same set of view states. So
from
> the child components, I want to bind to the currentState of the
> parent, so that when something changes the parent state, the view
> states of the children will automatically change accordingly. How
> might I do this?
>
> Bruce
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/