Murphos - 5 months ago 37

ActionScript Question

I'm currently trying to create a system where a function will roll for a new number everytime it is called (So I can then use that output to reset the scene with a new number (Number calls an array)). Currently this is my set up;

`function randomNum():Number{`

return this(Math.round(Math.random()*range) + minLimit);

};

The above is the function I have made to calculate new numbers on the fly. All relevant variables below;

`var output = randomNum();`

function randomFruit():String{

return fruits[output];

}

So pretty much the random number function rolls providing a new number for the output variable, which is then used to pull a new item out of an array. The issue I'm getting is that the random number function isn't returning any values, thus causing errors. Does anyone know how to fix this? I'm uncertain if this is the best way to reroll a new item out of an array but it's the easiest implementation I can think of.

Cheers for any assistance, as I've reached my wits end trying numerous fixes to no avail :/

Answer

Remove this:

```
function randomNum():Number{
return Math.round(Math.random()*range) + minLimit;
};
```