|
|
Search Tutorials
The Fla file: Actionscript for buttons, accessing individual child nodesIn the next function we will get access to child nodes by using another loop. Compare by using trace the contents of the var modelsDyscryption of the previous function with this function and see the difference.
//here we use a new argument for the function
function findModels(myModel) {
var myModel;
var modelName;
for (var count02=0; count02<=myModel.childNodes.length; count02++) {
if (myModel.childNodes[count02].nodeName.toLowerCase() == modelName) {
//we now have access to one childnode
//now the var modelsDescryption holds only the contents of the first Child of
//the childnode "modelName". modelName can be any of
//the child nodes of our XML document
modelsDescryption = myModel.childNodes[count02].firstChild;
//this will show the firstChild content in the scrollbar textfield
InstanceName_0.text = modelsDescryption;
//here we are accessing the attribute "name"
headline = myModel.childNodes[count02].attributes.name;
//here we are accessing the attribute "photo"
pic = myModel.childNodes[count02].attributes.photo;
//we load the swf into an empty MC
loadMovie(pic,"modelHolder");
}
}
}
}
|
||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||
|