Posted By

lzyy on 04/09/09


Tagged


Versions (?)

随机不重复数组内容


 / Published in: ActionScript 3
 

  1. var _arr:Array = new Array(1,3,5,7,9,32,43,45);
  2. var _length = _arr.length;
  3. for (var i = 0; i < _length; i++) {
  4. var rnd = Math.floor(Math.random() * _arr.length);//对应数组的key
  5. trace(_arr[rnd]);
  6. _arr.splice(rnd, 1);
  7. }

Report this snippet  

You need to login to post a comment.