Interesting what you're trying to do, maybe casting your child as the
container (i.e Canvas, TitleWindow) will work, give it a shot.
Well, I've tried to create a temp var, assign it as a Canvas and then apply it, but it's the same result. Flex tells me that it cannot convert the XMLList...
var temp:Canvas = Canvas(event.item.@label);
mainStack.selectedChild = temp;
I've also tried assigning the @label to an array... same result. I need to convert the XMLList.item.@label to either a Container or a Canvas... there's got to be a way!
Silly me that would've never work, I'm sorry for suggesting that. I think if you post the code that you use to create your viewstacks using the xml file. We'll be able to come up with an answer.
Unfortunately I'm not at my office right now but i will outline the code:
load's xml for menubar
once menubar has been created,
loop through XMLList and create appropriate canvas' for the static ViewStack "mainStack"
once the loop has completed, you can now use the application.
click on menubar links and the menubarhandler is called
mainStack.selectedChild = my code that isn't working ...
I hope that makes sense... it really doesn't matter how the code looks, im just doing a standard loop and calling a "createCanvas" function and passing in the name of the canvas to create. Then I addChild(can) within the ViewStack (mainStack).
Here's the answer:
When dynamically creating Canvas' for the viewstack, instead of assinging the canvas.id and trying to target that id (returns null), you assign canvas.name. This allows you to use the following syntax:
mainStack.selectedChild = Container(mainStack.getChildByName(event.item.@label.toString()));
This was a good post. I ran into the same problem.
Thanks for the help.