# Trying to pass vars to random function!

**URL:** <https://forum.kirupa.com/t/trying-to-pass-vars-to-random-function/241091>\
**Category:** Uncategorized\
**Created:** [October 9, 2007, 10:55pm UTC](https://forum.kirupa.com/t/trying-to-pass-vars-to-random-function/241091 "2007-10-09T22:55:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kredd](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kredd](https://forum.kirupa.com/u/kredd)\
**Post date:** [October 9, 2007, 10:55pm UTC](https://forum.kirupa.com/t/trying-to-pass-vars-to-random-function/241091/1 "2007-10-09T22:55:50Z")

</div>

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 ☹

any ideas? i’m using CS3. thanks!

```auto

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

```

```auto

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

```
