Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : Dynamic Movie Clip construct


tofletch
4/23/2004 7:57:30 PM
hello,

I'm attempting to dynamically place a ComboBox on the scene, and then
dynamically add items to the drop down list - all from XML. As I parse through
my XML file, when I encounter a specific type of entry, I want to create a
dropdown list that contains information from the childNodes.

I added a movie clip called "dropdown" to the library that just contains a
ComboBox.

I tried this...
----------------------------------[b]
_root.attachMovie("dropdown", "item1", 1);
_root["item1"]._x = 10;
_root["item1"]._y = 10;

myOptions = myXMLItem.childNodes;
_root["item1"].rowcount = 0;
for (m=1; m<=myOptions.length; m++){
if (myOptions[m].attributes.Value <> undefined){
_root["item1"].addItem(myOptions[m].attributes.Value);
}
}[/b]

The problem seems to be that the onClipEvent(construct) which initializes the
movie clip instance and makes it a combobox is called after I'm all done
creating it. Therefore, the additem call is not doing anything. I know for a
fact that the construct is called once I'm done, but I don't know how to -wait-
for that to finish before I attempt to add items. The _x and _y settings are
correctly placing the movieclip, but the internal settings of the combobox
inside the movie clip seem to be what I'm having trouble setting.

I also tried giving the ComboBox an instance name of "mycombo" inside the
movie clip. And then changing the additem call to this...
[b]_root["item1"].mycombo.addItem(myOptions[m].attributes.Value);[/b]
That didn't work either.

I've searched far and wide (books, Internet, Macromedia.com) and cannot find
any documentation on the onMovieClip(construct) function that is automatically
called on a component.

Your thoughts and ideas are great appreciated.
tofletch
Dinghus
4/23/2004 9:36:06 PM
A few things that may or may not relate. I could be out in left field here.

Why are you using _root["item1"] instead of just item1 like item1._x ? Or
_root.item1

Also try
if(myOptions[m].attributes.Value != undefined)
AddThis Social Bookmark Button