Fire effects can be difficult to create, as they require advanced use of ActionScript and can take a lot of time to accomplish. In this Quick Tip, I'll introduce you to an ActionScript class that will help you speed up the process.
Final Result Preview
Let's take a look at the final result we will be working towards:
Step 1: Brief Overview
Using a brilliant class called TeraFire, we will recreate a candle flame. You can download the source of the class from the developer's site.
Step 2: Set Up Your Flash File
Launch Flash and create a new Flash Document, set the stage size to 320x280px and the frame rate to 24fps.
Step 3: Interface
This is the interface used in the example, a background previously created to place the resulting flame. You can find it in the FLA in the source download.
Step 4: ActionScript
Create a new ActionScript Class (Cmd+N), save the file as Main.as, and write the following lines; please read the comments in the code to fully understand the class behavior.
1 |
|
2 |
package
|
3 |
{
|
4 |
import flash.display.Sprite; |
5 |
import com.trick7.effects.TeraFire; //Import TeraFire class |
6 |
|
7 |
public class Main extends Sprite |
8 |
{
|
9 |
public function Main():void |
10 |
{
|
11 |
/* Creates a terafire instance */
|
12 |
|
13 |
var fire:TeraFire = new TeraFire(); |
14 |
|
15 |
/* Position the fire particle */
|
16 |
fire.x = 158; |
17 |
fire.y = 130; |
18 |
|
19 |
/* Add to stage */
|
20 |
addChild(fire); |
21 |
}
|
22 |
}
|
23 |
}
|
You can customize the way the particle looks by passing parameters to the TeraFire constructor. These are the parameters available:
- xPos: The x position to create the fire, default is 0
- yPos:The y position to create the fire, default is 0
- fireWidth: Width of the resulting fire, default is 30
- fireHeight: Height of the resulting fire, default is 90
Step 5: Document Class
Add the class name to the Class field in the Publish section of the Properties panel.
Conclusion
Now you're aware of this easy way to create fire for your movies, you'll find it comes in really handy when building games. Implement your own!
I hope you liked this tutorial, thank you for reading!