Flash AS3 Example Tutorial: Rapid production of smoke animation

Source: Internet
Author: User

This example uses the flash to make the smoke animation quickly, mainly utilizes the AS3 class to realize.

First we make a photo of the smoke in Photoshop, which is mainly achieved with Photoshop brushes.

Figure 1

Figure 2

Figure 3

We then move into flash and turn to the original movie clip, named Smokepuff. Then we open the library, then right click on the component and set the link.

Figure 4

Then edit the category and the code below.

Package Com.asgamer.graphics

{

Import Flash.display.BlendMode;

Import Flash.display.MovieClip;

Import flash.events.Event;

public class Smokepuff extends MovieClip

{

public Var Vx:number;

public Var Vy:number;

Public Function Smokepuff (): void

{

Alpha = Math.random ();

VX = Math.random ()-math.random ();

VY = Math.random () * 3-5;

ScaleX = ScaleY = Math.random ();

AddEventListener (Event.enter_frame, loop, False, 0, true);

}

Private function Loop (e:event): void

{

Alpha-= 0.01;

Y + + vy;

x + VX;

ScaleX = ScaleY + 0.02;

if (Alpha < 0)

Removeself ();

}

Private Function removeself (): void

{

RemoveEventListener (Event.enter_frame, loop);

Parent.removechild (this);

}

}

}

The properties of the document are:

Figure 5

Then we create a main.as

Package

{

Import Flash.display.Stage;

Import Flash.display.MovieClip;

Import flash.events.Event;

Import Com.asgamer.graphics.Smokepuff;

Import Flash.display.Sprite;

public class Main extends Sprite

{

Public Function Main (): void

{

AddEventListener (Event.enter_frame, loop, False, 0, true);

}

Private function Loop (e:event): void

{

var smokepuff:smokepuff = new Smokepuff ();

smokepuff.x = 250;

SMOKEPUFF.Y = 250;

Stage.addchild (Smokepuff);

}

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.