Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.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 Flash Actionscript 3“;“限制转弯次数”;_Actionscript 3_Flash - Fatal编程技术网

Actionscript 3 Flash Actionscript 3“;“限制转弯次数”;

Actionscript 3 Flash Actionscript 3“;“限制转弯次数”;,actionscript-3,flash,Actionscript 3,Flash,我正在建立一个随机拼写测验,效果很好。为了让它更好,我想添加很多单词,但如果我这样做了10个,我只希望用户拼写这些单词中的10个正确。我的问题是我从哪里开始?假设你在列表中有你的话: var words:Array = ['chicken', 'pig', 'cow', 'sheep']; 洗牌单词列表 执行从 吃一片 在本例中,切片仅包含两个元素,但可以将其更改为10或任意数字 现在,您可以使用selectedWords中的单词进行拼写测验。b非常感谢您的回答这是我脑海中的想法。谢谢 f

我正在建立一个随机拼写测验,效果很好。为了让它更好,我想添加很多单词,但如果我这样做了10个,我只希望用户拼写这些单词中的10个正确。我的问题是我从哪里开始?

假设你在列表中有你的话:

var words:Array = ['chicken', 'pig', 'cow', 'sheep'];

洗牌单词列表 执行从

吃一片
在本例中,切片仅包含两个元素,但可以将其更改为10或任意数字


现在,您可以使用
selectedWords
中的单词进行拼写测验。

b非常感谢您的回答这是我脑海中的想法。谢谢
function shuffle(array) {
  var m = array.length, t, i;

  // While there remain elements to shuffle…
  while (m) {

    // Pick a remaining element…
    i = Math.floor(Math.random() * m--);

    // And swap it with the current element.
    t = array[m];
    array[m] = array[i];
    array[i] = t;
  }

  return array;
}

var shuffledWords:Array = shuffle(words);
trace(shuffledWords); // Prints ['sheep', 'chicken', 'cow', 'pig']
var selectedWords = shuffledWords.slice(0, 2);
trace(selectedWords); // Prints ['sheep', 'chicken']