随机启动时间移动剪辑剪辑、时间

2023-09-08 11:53:07 作者:辣手摧花

我想这些不断增长的圆圈影片剪辑开始在设定的时间量的随机时间,然后不会再重复,直到整部影片循环。那有意义吗?附件是一个FLA和SWF以显示我想要的只是,在过程中,他们还没有开始在随机时间。

I want these growing circle movie clips to start at random times within a set amount of time and then not repeat again until the whole movie loops. Does that make sense? Attached is a fla and swf to show what I want except, over course, they're not yet starting at random times.

在动画应该是所设时间长 在动画应该重复,但随机起始时间为每个MC 在所有MC动画之前应发挥再次循环 在没有MC应该发挥,直到10帧

FLA https://mega.co.nz/#!8Nwi0KzZ!QlutQQVo-KoPyNaGta9-7GLsYFthI0lMSAqTqtIIiDY

瑞士法郎 https://mega.co.nz/#!4cRFjZ5A!H0ndXA2DfFh79wJGua2Tgk9SquZ1rpEzZE3RCPwYfW4

任何帮助将是可爱的!

谢谢, 罗林

推荐答案

您必须停止循环影片剪辑的第1帧,然后根据使用内置函数的setTimeout的一个随机数进行播放。

You have stop the circle movie clip at frame 1, then play it based on a Random number using the setTimeOut built in function.

您可以使用此功能生成一个随机数:

you can generate a random number using this function:

function GenerateRandomNumber(max:Number, min:Number = 0):Number
{
     return Math.random() * (max - min) + min;
}

您可以使用参数的最大值定义设定的时间量和最小是这样的:

You can define the set amount of time using parameters max and min like this:

GenerateRandomNumber(4,1);

这会给你1到4秒之间的任意时间。如你愿意,可以改变这些值。

This will give you random time between 1 and 4 seconds. You can change these values as you wish.

您更好的在圈内影片剪辑的父定义此功能,以便如果你想重新使用它在其他地方。

you better define this function in the parent of the circle movieclips in order to reuse it in other places if you want.

然后,在圆影片剪辑,你停止它的最后一帧,则需要检查所有圆圈影片剪辑停止或不重新播放动画。通过增加一个计数器,所有完成的电影剪辑的总数你做到这一点。

Then, at the last frame of the circle movie clip where you stop it, you need to check if all circle movie clips are stopped or not to replay the animation. You achieve this by incrementing a counter with the total count of all finished movie clips.

您可以使用位于圆影片剪辑的父定义的函数来跟踪所有的人都像这样做:

You can do this using a function defined at the parent of the circle movie clips to keep track of all of them like this:

var CircleMcsPlayedCount:int = 0;
var TotalCirclesCount:int = 12;

function CircleMcFinishedPlayback()
{
     CircleMcsPlayedCount++;
     if(CircleMcsPlayedCount == TotalCirclesCount){
         CircleMcsPlayedCount = 0;
         this.gotoAndPlay(1);
     }
}

您可以使用此行的code在圆影片剪辑的最后一帧称之为:

you can call it using this line of code at the last frame of the circle movie clip:

MovieClip(parent).CircleMcFinishedPlayback();

在此功能,当账户等于影片剪辑的总数,设置计数再次为零,再次移动播放头到第一帧重新播放动画。你可以把任何code这个功能,你需要各界播放完毕后要执行的if语句中。

In this function, when the account equals the total number of movieclips, you set the count to zero again and move the playhead to the first frame again to play the animation again. You can put any code in this function inside the if statement that you need to be executed after all circles finishes playback.

我已经修改了文件,你上传并应用所有的变化,如果你想你自己尝试之前看到它在行动。

I have modified the file you uploaded and applied all the changes in case you want to see it in action before you try it yourself.

下面是文件:

https://mega.co.nz/#!JxtFgTJK!LWpuFCXTYrkmMK_6tm_1cAp3MKpB1h33URufrr1Pkk4

我有救了它作为闪存CS4中,因为我不知道你的版本我没有旧版本。

I have saved it as flash cs4 as I don't know your version and I have no older version.