RSS link icon

.

Growing cloud engine with actionscript 3


Hi I have been playing a lot with different ways to produce smoke and clouds these days, both on frame by frame animations and like actionscript engines.

So here I just made a simple growing cloud particle system with flash actionscript 3.0, and Im going to explain to you how you can make your own animated clouds with flash.

First we need to make one movie clip containing a cloud graphic, to work with, its quite simple just use the brush tool and draw a shape like I did below.

actionscript clouds engine

Right click and convert it into a movie clip, then go to the filters panel and add a blur filter with these settings

actionscript clouds engine

Now we need to give this cloud an instance name, I named mine cloud_mc.

That we all the particle stuff, now we need only need the technical stuff, by that I mean the actionscript coding, so open up your actionscript panel and past this code into it.

 

The growing speed variable

var yspeed:Number = (Math.random() * 0.8);

 

Here we set the clouds start properties such as position, rotation start and alpha.

setCloudProperties();
function setCloudProperties():void {
    cloud_mc.alpha = 100;
    cloud_mc.x = 141;
    cloud_mc.y = 180;
    cloud_mc.rotation = Math.random() *360;
}
// An eventlistener to make the cloud grow. (remember to set this outside the function).
cloud_mc.addEventListener(Event.ENTER_FRAME, doCloud);

 

This is all it take to make the cloud engine work and generate some random shape and growth and rotations.

function doCloud(event:Event):void {
    cloud_mc.alpha -= 0.3;
    if (cloud_mc.alpha<50) {
    cloud_mc.alpha -= 0.4;
}

if (cloud_mc.alpha<1) {
	setCloudProperties();
}
	cloud_mc.y = cloud_mc.y - yspeed;
}

Just think of the endless possibilities with such simple code to generate a random cloud growth.


soules says: 2008-10-13

i got the same problem has etyp76, could you pls tell me what the problem is or put a new description on this tutorial. thanks, soules

etype76 says: 2008-09-05

It is not working for me. The cloud I created (cloud_mc) with a blur effect stays in the same shape and slowly travels up the screen undistorted and not rotating, bigger or smaller. then when it gets past the top, it resets itChr(34)s position back at the bottom only at a different angle... I have played with the x, y, alpha, rotation, etc

Admin Bob says: 2008-09-15

Hi etype76, try sending me your flash file, and I will see if I can help you fix the problem.