you would use attchMovie
this example has 3 options..a component button, and custom template clip, and the comboBox component..
what I did was put a comboBox component on the stage (called: videoCombo)
and in the library I had TWO objects:
1.) a regular component button
2.) a movieClip, that is nothing more than a outline (like a rectangle button) and a dynamic textField... textField name: buttonField. I also set the linkage property for this movieClip to be: buttonTemplate...and the NEW instance name to be given when attached: tempButton (+[i])
here is the code:
Code:
import mx.utils.Delegate;
var rootNode:XMLNode;
var videosNode:Array;
var totalVideos:Number;
var myVideos_xml = new XML();
myVideos_xml.ignoreWhite = true;
myVideos_xml.onLoad = Delegate.create(this, getTotalVideos);
myVideos_xml.load("videoXML.xml"); //local version
//
function getTotalVideos(success):Void {
trace("Get Total Vids");
if (success == true) {
trace("Load OK");
rootNode = myVideos_xml.firstChild;
videosNode = rootNode.childNodes;
totalVideos = videosNode.length;
placeButtons();
this.onEnterFrame = Delegate.create(this, function() {
populateComponents();
delete this.onEnterFrame;
}//end Function
); //end Delegate
}else {
trace("Load Failed");
}
}
//
function placeButtons():Void {
trace("Place buttons");
//Define how many columns
var columns:Number = 1;
//Define the item vSpacing;
var vSpacing:Number = 10;
//Define the item hSpacing;
var hSpacing:Number = 0;
for (i=0; i<totalVideos - 1; i++) {
//template buttons
var attachProduct:MovieClip = attachMovie("buttonTemplate", "tempButton"+i, this.getNextHighestDepth());
attachProduct._x += 10;
attachProduct._x += i * 125;
attachProduct._y += 20;
//attachProduct._y += i * 45;
//attachProduct._y = Math.floor(i / columns) * hSpacing; //only used with multiple columns
//attachProduct._x = Math.floor(i % columns) * vSpacing; //only used with multiple columns
//component buttons
var attachProduct2:MovieClip = attachMovie("Button", "compButton"+i, this.getNextHighestDepth());
attachProduct2._x += 10;
attachProduct2._x += i * 125;
attachProduct2._y += 50;
}
}
//populate
function populateComponents():Void {
trace("Populate Components");
for (j = 0; j < totalVideos-1; j++) {
//buttonTemplate data
var videoName:String = videosNode[j].firstChild.nodeValue;
var obj = this["tempButton" + j];
obj.buttonField.text = videoName;
//componentButton data
var videoName:String = videosNode[j].firstChild.nodeValue;
var obj = this["compButton" + j];
obj.label = videoName;
//comboBox data
var videoName:String = videosNode[j].firstChild.nodeValue;
trace("Video name: "+videoName);
_root.videoCombo.addItem(videoName);
}
}
and here is the .fla:
www.dmstudios.net/xml_attachClip.zip
I also have a link in my footer about attachMovie...but it uses a text loadVar Object..this one has the XML object you used..