Ok, I am requesting the collection brain power to get over this mental
hump of how to add dynamic buttons and have them control a view stack of
modules.
I have 4 different portals for kids, siblings, parents, and hospitals.
When the user logs in, it finds their type and loads an XML document
containing module file names and button names. Each portal contains
different number of modules and depending on the XML document, that can
change.
Right now I am looping through the XML and creating LinkButtons with the
<name> node being added as the label. Problem is that I want to then
load the modules in a viewstack and use the buttons to switch through
the stack using the index of the loop to tell the button what
selectedIndex of the stack to show. (I.E. the first loop, i = 0, so the
MouseClick eventlistener will set the viewstack's selectedIndex to 0
(the first level). I want the module to match up with the button. Hope
that makes sense....
Anyways I am adding an embedded function to the MouseClick eventlistener
I am associating with each LinkButton before I addChild() it to the
application. Problem is, the index I am associating with it is wrong
when I attempt to trace it.
Ok, all that to show you this and hope you can help me. What I want is
to loop through the XML document, create LinkButtons with the label from
the <name> node and then, when clicked, change the ViewStack (appVS) to
the index that matches the current loop. I am up for both modifying my
code (or pointing out what is wrong) or a better idea.
public function init():void {
for (var i:int = 0; i < moduleList.module.length(); i++){
var button:LinkButton = new LinkButton;
button.label = moduleList.module[i].name;
button.setStyle("fontSize","12");
button.addEventListener(MouseEvent.CLICK,
function():void{appVS.selectedIndex=i;});
navACB.addChildAt(button, i);
}
}
The first button should be created, put in the 0 space on the navACB,
and move the ViewStack to the 0 level when clicked.
Next should be created, put it in the 1 space on the navACB, then move
the ViewStack to the 1 level when clicked...and so on.
Thanks!
------------------------------------
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location:
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo!
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:
[email protected]
[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/