// navigation
var picNum:Number = 3;
for (var i = 1; i<=picNum; i++) {
_root.nav["btn"+i].topText_mc.text = *;
_root.nav["btn"+i].alphaTo(30, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
}
My XML:
What I want is to get this trace(parseFloat(i)); to be my picNum variable. Tried a bunch of diffrent things but none worked. Maybe someone here knows?
var pArray = new Array();
var tArray = new Array();
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
if (success) {
var xmlData = this.firstChild.childNodes[0].childNodes[0];
for (var i = 0; i<xmlData.childNodes.length; i++) {
pArray.push(xmlData.childNodes*.childNodes[0].firstChild.nodeValue);
tArray.push(xmlData.childNodes*.childNodes[1].firstChild.nodeValue);
}
trace(parseFloat(i));
containerMC.loadPic(0);
picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
} else {
picInfo.text = "Unable to load external file.";
}
}
myXML.load("xml/XMLdata.xml")
i is already an integer, but it’s only available inside the for loop, that’s how for loops work.
Do you need it to be a float? Do you want access to i outside of the for loop? What, exactly, are you trying to accomplish?
I just solved my problem. Thanks anyway. What I was trying to do was to get the number of nodes populated with images in my xml file to setup my navigation. This is how I did it with the use of [COLOR=“Blue”]parseInt()[/COLOR]:
var pArray = new Array();
var tArray = new Array();
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
if (success) {
var xmlData = this.firstChild.childNodes[1].childNodes[2]; // sub1 = 0
for (var i = 0; i<xmlData.childNodes.length; i++) {
pArray.push(xmlData.childNodes*.childNodes[0].firstChild.nodeValue);
tArray.push(xmlData.childNodes*.childNodes[1].firstChild.nodeValue);
}
// navigation
var picNum = parseInt(i);
for (var i = 1; i<=picNum; i++) {
_root.nav["btn"+i].topText_mc.text = *;
_root.nav["btn"+i].alphaTo(30, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
}
_root.nav.btn1.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
_root.nav.btn1.enabled = false;
// load pictures
containerMC.loadPic(0);
picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
} else {
picInfo.text = "Unable to load external file.";
}
}
myXML.load("xml/XMLdata.xml")
Hmm, sorry but I thought I had it. A slightly diffrent question but in the same category, I think… jow can I make this work with my xml file? Can I make the childNodes* get different values? The first one for the <subnumber> and the second one for the <subinfo> tags?
In flash:
var pArray = new Array();
var tArray = new Array();
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
if (success) {
var xmlData = this.firstChild;
for (var i = 0; i<xmlData.childNodes.length; i++) {
pArray.push(xmlData.childNodes*.childNodes*.childNodes[0].firstChild.nodeValue);
tArray.push(xmlData.childNodes*.childNodes*.childNodes[1].firstChild.nodeValue);
}
// navigation
var picNum = parseInt(i);
for (var i = 1; i<=picNum; i++) {
_root.nav["btn"+i].topText_mc.text = *;
_root.nav["btn"+i].alphaTo(30, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
}
_root.nav.btn1.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
_root.nav.btn1.enabled = false;
// load pictures
containerMC.loadPic(0);
picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
} else {
picInfo.text = "Unable to load external file.";
}
}
myXML.load("main1/xmlData.xml")