Groups | Blog | Home
all groups > flash actionscript > august 2007 >

flash actionscript : comboBox selectedIndex doesn't work


stephan.k
8/26/2007 5:31:41 PM
Hello forum

I'm having problems with the comboBox. It must be a a bug of some sort and I
was wondering if anyone out there knows of a workaround.

I am using 2 movieclips which each contain a comboBox instance. I'm using the
same code for both of boxes to fill them with data from an xml file.
Everything works fine. The only strange thing is when I use the selectedIndex
property once it doesn't seem to work again, meaning everytime I reload either
one of the movieClips the comboBox has no selected value (first text in the
box, visible before it opens).

Any pros out there aware of this issue and could pin point the bug, what
creates it and how to get around it?

Any insight appreciated.

Much thanks

stephank
stephan.k
8/26/2007 6:21:08 PM
stephan.k
8/26/2007 6:43:26 PM
I did some more testing:

Does it have something to do with some initiation delay of the comboBox
possibly? Let's say for example the comboBox is not properly initiated/loaded
when I set the selectedIndex?

The following code doesn't work when I attach the movieClip mc which contains
the comboBox. It works though if the comboBox is on the root to begin with/it
is not attached.


function init(){
_root.attachMovie("mc","mc",1);

_root.mc.comboBox.labelField = "name";
_root.mc.comboBox.addItem({name: "Nina", age: 25});
_root.mc.comboBox.addItem({name: "Patrick", age: 24});
_root.mc.comboBox.addItem({name: "Luciano", age: 35});

_root.mc.comboBox.selectedIndex = 2;

}


button.onRelease = function(){
init();
}
AddThis Social Bookmark Button