简体   繁体   English

函数不返回值(错误1170; ActionScript 3.0)

[英]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)). 我目前正在尝试创建一个系统,每次调用该函数时,该函数都会滚动一个新数字(因此,我可以使用该输出用一个新数字重置场景(Number调用数组))。 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;
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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