# Coverting a (php)variable to numeric value in flash

**URL:** https://forum.kirupa.com/t/coverting-a-php-variable-to-numeric-value-in-flash/57483
**Category:** Uncategorized
**Created:** [July 13, 2004, 6:17pm UTC](https://forum.kirupa.com/t/coverting-a-php-variable-to-numeric-value-in-flash/57483 "2004-07-13T18:17:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![beenetto](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@beenetto](https://forum.kirupa.com/u/beenetto)
#### Post date: [July 13, 2004, 6:17pm UTC](https://forum.kirupa.com/t/coverting-a-php-variable-to-numeric-value-in-flash/57483/1 "2004-07-13T18:17:50Z")

</div>

ok,

I got this script from axis100 yesterday  
(php)  
// Open directory  
$myDirectory = opendir(“path o\directory”);  
// get each entry  
while($entryName = readdir($myDirectory))  
{  
$dirArray[] = $entryName;  
}  
// close directory  
closedir($myDirectory);  
// count elements in array  
$indexCount = (count($dirArray));  
// return the amount of files in the directory to flash with :  
print “&myVariable=” . urlencode($indexCount+1);

(…and this is the flash part)

dirCount = new LoadVars(); dirCount.load(“http://path\_to/listdirectory.php”);  
dirCount.onLoad = function(success) {  
if (success) {  
\_root.myVariable = this.myVariable;  
} else {  
trace(“directory listing error”);  
}  
}

its working fine long as I onli display the number, but my problem is that I need myVariable to be a numeric value in flash. I’ve tried  
Number(myVariable), but when I trace it it returns: NAN  
Does anybody has an idea why and how to convert it.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 13, 2004, 7:01pm UTC](https://forum.kirupa.com/t/coverting-a-php-variable-to-numeric-value-in-flash/57483/2 "2004-07-13T19:01:57Z")

</div>

use parseInt(). here’s an example:

[AS]  
var myString = “33”;  
var myNumber = parseInt(myString);  
[/AS]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 13, 2004, 11:27pm UTC](https://forum.kirupa.com/t/coverting-a-php-variable-to-numeric-value-in-flash/57483/3 "2004-07-13T23:27:57Z")

</div>

It’s just what i needed!  
thanks, it works just fine.
