Flash脚本-创建重复的动画片段

tech2024-05-30  72

Download the sample files here.

在此处下载示例文件 。

Note that this tutorial assumes that you know how to create buttons and text fields.

请注意,本教程假定您知道如何创建按钮和文本字段。

1. First, create a button and label it "make clones".

1.首先,创建一个按钮并将其标记为“ make clones”。

2. Create a text field as shown in the above movie. Give it a variable name "no_clones".

2.创建一个文本字段,如以上电影所示。 给它一个变量名“ no_clones”。

3. Create a movie clip of your choice, which we can duplicate. I created a circle object with a gradient.

3.创建您选择的影片剪辑,我们可以将其复制。 我创建了一个带有渐变的圆形对象。

4. Give the movie clip an instance name of "clone".

4.为影片剪辑指定实例名称“ clone”。

5. Now, in the default layer’s first key frame, insert this action:

5.现在,在默认层的第一个关键帧中,插入以下操作:

// set variable clips=value in text field. clips = no_clones;

6. Right click the button and insert these actions:

6.右键单击按钮并插入以下操作:

/on (release) { // get the current x pos of the clone movie mov_x = getProperty("/clone",_x); //Check if the text field is empty if empty set it to 1 if(no_clones == "") { no_clones = 1; } // Use for loop to remove existing movie clip for(i=1; i<=clips; i=i+1) { removeMovieClip ("/clone" add i); } // Use for loop to create duplicate movies. for (i=1; i<=no_clones; i=i+1) { mov_x = mov_x + 50; duplicateMovieClip ("/clone", "clone" add i, i); setProperty ("/clone" add i, _x, mov_x); } //set variable clips = no_clones. clips = no_clones; }

I’ve commented the above script so that it’s easier for you understand. But that’s all you need to do: it’s time to test the movie.

我评论了上面的脚本,以便您更容易理解。 但这就是您所要做的:现在是测试电影的时候了。

Learning to create duplicate movie clips in flash is very usefull. It can be used to create a lot of effects — happy experimenting!

学习在Flash中创建重复的影片剪辑非常有用。 它可以用来创建很多效果-尝试愉快!

翻译自: https://www.sitepoint.com/create-duplicate-movieclips/

最新回复(0)