Trying to pass vars to random function!

hello all, the code below works as written IF var hi is set to an actual number(ex. 6) but i need var hi to equal “_global.itemCount”.

if i trace _global.itemCount i get an actual number but whenever i use it in the equation below it results in NaN instead of number.

so how do i convert the itemCount value to a number type var? the second section of code is my attempt to do so :frowning:

any ideas? i’m using CS3. thanks!


//load xml function
_global.itemCount = fourfold.firstChild.childNodes.length;
 
//outside xml function
var hi:Number = 6; // should be _global.itemCount
var lo:Number = 1;
var rand:Number = Math.floor(Math.random() * (hi - lo)) + lo;
 
setFF(rand); // send random number to the apps function
 
trace(rand); //random number
 


//try to convert itemCount to Number type?!?
var trans:Number = _global.itemCount;
 
//no dice
trace(trans) = undefined