# How to use this parseFloat() number?

**URL:** <https://forum.kirupa.com/t/how-to-use-this-parsefloat-number/204930>\
**Category:** flash\
**Created:** [October 24, 2006, 6:33pm UTC](https://forum.kirupa.com/t/how-to-use-this-parsefloat-number/204930 "2006-10-24T18:33:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bennymartensson](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bennymartensson/32/1317_2.png) [@bennymartensson](https://forum.kirupa.com/u/bennymartensson)\
**Post date:** [October 24, 2006, 6:33pm UTC](https://forum.kirupa.com/t/how-to-use-this-parsefloat-number/204930/1 "2006-10-24T18:33:38Z")

</div>

**I have this to build my nav;**

```auto

// 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?

```auto

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")

```

---

<div class="post-metadata">

**Author:** ![Kraken](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kraken/32/2910_2.png) [@Kraken](https://forum.kirupa.com/u/Kraken)\
**Post date:** [October 24, 2006, 7:44pm UTC](https://forum.kirupa.com/t/how-to-use-this-parsefloat-number/204930/2 "2006-10-24T19:44:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bennymartensson](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bennymartensson/32/1317_2.png) [@bennymartensson](https://forum.kirupa.com/u/bennymartensson)\
**Post date:** [October 24, 2006, 8:25pm UTC](https://forum.kirupa.com/t/how-to-use-this-parsefloat-number/204930/3 "2006-10-24T20:25:33Z")

</div>

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]:

```auto

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")

```

---

<div class="post-metadata">

**Author:** ![bennymartensson](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bennymartensson/32/1317_2.png) [@bennymartensson](https://forum.kirupa.com/u/bennymartensson)\
**Post date:** [October 24, 2006, 9:03pm UTC](https://forum.kirupa.com/t/how-to-use-this-parsefloat-number/204930/4 "2006-10-24T21:03:55Z")

</div>

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:

```auto

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")

```

And my xml:

```php

<?xml version="1.0" encoding="iso-8859-1" ?>
<main>
	<subnumber><!-- SUB 1 -->
		<subinfo>
			<path>main1/images1/01.jpg</path>
			<info><![CDATA[<p>main1, sub1</p>]]></info>
		</subinfo>
		<subinfo>
			<path>main1/images1/02.jpg</path>
			<info></info>
		</subinfo>
		<subinfo>
			<path>main1/images1/03.jpg</path>
			<info></info>
		</subinfo>
	</subnumber>
	<subnumber><!-- SUB 2 -->
		<subinfo>
			<path>main1/images2/01.jpg</path>
			<info><![CDATA[<p>main1, sub2</p>]]></info>
		</subinfo>
		<subinfo>
			<path>main1/images2/02.jpg</path>
			<info></info>
		</subinfo>
	</subnumber>
</main>

```
