Make clouds run over the sky in Flash
In this Macromedia Flash tutorial I will show you how to make clouds then via actionscript make them run over the sky, also create duplications of the sky's so they continue.
1.
First of we need to make an envioment for this scene, so I made some grass hills out of an oval shape.
Made a sky beneath it with a gradient color from blue to white, as shown in the image below.
2.
Now in the layers panel make a new layer and name it clouds.
3.
Drag an white oval on the stage, hold down the alt key and drag some corners in from the oval as shown in the image below.
So you end up with a cloud looking like this.
Now right click and convert the cloud to a movie clip.
Give it an instance name in the properties panel, (cloud1)
4.
Place the cloud all the way out to the left of the stage.
Click the cloud and go to the actionscript panel, type in the code from below.
onClipEvent (enterFrame) {
_x += 10
}
Test your movie and you will see your cloud moving from left to right, over the stage.
The onClipEvent (enterFrame) says to flash that the following code will repeat over and over again.
_x referes to the x axis of our cloud and this tells flash to add 10 to the x position everytime t repeats.
5.
Now for the code to duplicate the cloud object.
Click the frame 1 in the timeline and go to the actionscript panel.
Type in the following code. (eventhough it may seem confusing).
var DoDup = function() {
i++
duplicateMovieClip(_root.cloud1, "cloud1"+i, -1);
setProperty("cloud1" + i, _x, -40);
setProperty("cloud1" + i, _y, random(10));
}
var intervalID = setInterval(DoDup, 4000);
------------------------------------------------------------------
Now first we make a function, the function container looks like this:
(and its name is DoDup)
var DoDup = function() {
}
The content of the function is
first to declare an instance i as a number so it adds 1 to the number every time
i++
duplicateMovieClip(_root.cloud1, "cloud1"+i, -1);
This takes the cloud1 movieclip from before and creates a new one or it, and we give it the same name as the first just adding the number to the end of it (i), and because we have made some background layers we need to put the movie clips depth to -1 so we are sure its on top of the sky and grass hills.
setProperty("cloud1" + i, _x, -40);
setProperty("cloud1" + i, _y, random(10));
Now we set some properties, we need to place the new movieclip some place on the stage.
In the x axis I placed it at -40 and the y axis I placed it at a random 10 (so sometimes it at the top and sometimes a bit lower).
Now we need something to tricker the function.
var intervalID = setInterval(DoDup, 4000);
This is a timer, it counts a interval, 4000 is 4 seconds, and then it trickers the function every 4 seconds.
Now test the movie and you should have something like my result.