AS3精辟代码若干--random

来源:互联网 发布:n个球放入m个盒子C语言 编辑:程序博客网 时间:2024/06/09 15:06

AS3精辟代码若干--random

 ★★★random 随机 且不同于上一个

  private var old_vv:int = 1;
  private function random(n:int):int {
   var i:int=  Math.ceil(Math.random()*3);
   if (old_vv == i) {
    return random();
   }
   return i;
  }

 ★★★random 随机
as2 mc.gotoAndPlay(random(mc._totalframes));
as3 mc.gotoAndPlay(Math.ceil(Math.random()*(mc.totalFrames)));


as2 random(3);
as3 Math.ceil(Math.random()*3);


function random(n:int):int{
return Math.ceil(Math.random()*n);
}

原创粉丝点击