简体   繁体   中英

Function does not return a value (Error 1170; ActionScript 3.0)

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

Remove this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM