Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 带有动作脚本3的倒计时计时器的随机开始数_Actionscript 3_Random_Timer - Fatal编程技术网

Actionscript 3 带有动作脚本3的倒计时计时器的随机开始数

Actionscript 3 带有动作脚本3的倒计时计时器的随机开始数,actionscript-3,random,timer,Actionscript 3,Random,Timer,我正在尝试制作一个带有倒计时的flash游戏,它将以一个随机数开始。从10秒开始以任何数字开头的东西。-15秒。我对动作脚本非常陌生,这是我的第一个游戏。我让计时器从10点开始工作到1点 以下是我到目前为止得到的信息: var fl_SecondsToCountDown_2:Number = 10; var fl_CountDownTimerInstance_2:Timer = new Timer(1000, fl_SecondsToCountDown_2); fl_CountDownTim

我正在尝试制作一个带有倒计时的flash游戏,它将以一个随机数开始。从10秒开始以任何数字开头的东西。-15秒。我对动作脚本非常陌生,这是我的第一个游戏。我让计时器从10点开始工作到1点

以下是我到目前为止得到的信息:

var fl_SecondsToCountDown_2:Number = 10;


var fl_CountDownTimerInstance_2:Timer = new Timer(1000, fl_SecondsToCountDown_2);
fl_CountDownTimerInstance_2.addEventListener(TimerEvent.TIMER, fl_CountDownTimerHandler_2);
fl_CountDownTimerInstance_2.start();

function fl_CountDownTimerHandler_2(event:TimerEvent):void
{

if (fl_SecondsToCountDown_2 <= 1) {
    gotoAndStop(2);
}

trace(fl_SecondsToCountDown_2 + " seconds");
fl_SecondsToCountDown_2--;
}
var fl\u seconds to倒计时2:数字=10;
var fl_CountDownTimerInstance_2:计时器=新计时器(1000,fl_Second至倒计时_2);
fl_CountDownTimerInstance_2.addEventListener(TimerEvent.TIMER,fl_CountDownTimerHandler_2);
fl_CountDownTimerInstance_2.start();
函数fl_CountDownTimerHandler_2(事件:TimerEvent):无效
{
如果(fl_second to倒计时_2
Math.random()
返回一个从0到小于1的随机数。因此,如果将其与
n
相乘,则得到一个从0到小于n的随机数。将其转换为int将生成一个从0到
n-1
的随机整数。如果将
m
添加到它,则得到从
m
n-1
的随机整数。因此从10到15得到一个您需要执行以下操作:

var r:int = 10 + int(Math.random() * 6);

我应该把这个放在哪里?@Therobinson兄弟,你正在使用
fl\u seconds to countdown\u 2
作为计数器。所以用这个作为
fl\u seconds to countdown\u 2
的值。非常感谢!我得到了我需要的东西。