使形状在动作脚本的不同层中落下

时间:2013-10-13 13:17:45

标签: actionscript-3

编程新功能...我想让物体以不同的速度直接落入闪光灯中。有点像ascii艺术从顶部下降到画板底部的形状。有600件。所以必须有一种更好的自动化方法。问题是插图中的图稿是分层的。所以我想应用一个脚本来随机使每一层落下375像素。我使用的脚本用于创建形状和移动。不导入已经制作的形状......帮助!

我是否将动作脚本放在每个符号中?

提前致谢。 derob357

function moveDown(e:Event):void {      e.target.y += speed; /* e.target refers to circle_mc. We    are incrementing the y property to make it move down */       /* This will stop the animation when the movie clip reaches a certain point */      if(e.target.y >= 350)      {           circle_mc.removeEventListener(Event.ENTER_FRAME, moveDown);      } }

1 个答案:

答案 0 :(得分:1)

在您的变速中,您可以通过以下Math.random()函数轻松地使其成为随机速度:

var high:int = 10;
var low:int = 1;
var speed:Number = Math.floor(Math.random()*(1+high-low))+low;

这将生成1到10之间的随机数,更改变量高和低以更改限制。