Hi, i am writing this tutorial, to explain how to create a folder in your computer where to put all the libraries you can download from the web. This is called a class path, i.e. a folder where the flash IDE will search for class definitions. Flash has a default directory where it searches for standard Actionscript 3 classes. Now we are going to create and add a new folder to the Flash class path.
I create a folder on my desktop. I will call it Actionscript for convenience.
Whoa! The folder’s done. Now we have to make Flash IDE recognize it.
We open Flash, we go for Edit menu >> Preferences.
We select Actionscript in the left list and we access to the subpage where Actionscript preferences are set.
Now we have to click on the Actionscript 3.0 Settings… button.
This will open a new panel where we find:
- a dot
- $(AppConfig)/ActionScript 3.0/Classes
Now we click on the + sign to add an item to the list, that will be empty at first. We select it by clicking on it, and then we click the Browse to path button. We just have to browse to the Actionscript folder I created at the beginning, and then click Ok. The game is done.
Simply restart the flash IDE, and from this moment, every folder or file i will put into that directory, will be recognized by Flash.
I hope this is clear.
Let’s go for an example.
We download the Caurina Tweener Engine for AS3, from here.
We decompress the package to our desktop. In this case, everything inside this package must be copied to the Actionscript folder we created. In some cases, you will have to copy only particular folders. However, always follow instructions.
So copy the file in the folder. And you have your first library in your class path!
Enjoy!
I have been experimenting again with Flint Particle System, that you can find at flintparticles.org.
I made some smoke, modified from the FireAndSmoke version, already at the site
See the code
And made some rain too.
See the code
Enjoy!
Do you want to learn how to control your characters using the Keyboard? Learn how in this very simple tutorial, that build the basis of advanced game programming that will come in the next lessons!
Sit down, lesson is up, here!
Enjoy!
Hi!
Today’s lesson will be about creating a starfield with the Flint Particle System. It’s quiet easy, thanks to the simplicity of the system itself. Let’s jump in! Follow me!
- First of all, download the latest version of the Flint Particle System, you can download it here or by SVN. Decompress the archive and copy the files (under the org folder) in your lib directory. Don’t you know how to do this?
- We begin making an empty AS3 empty file in the flash IDE. We will prefer to set the Stage background in black, and our frame rate at 40 fps. I will choose to develop the starfield in a class, so i will click on an empty point of the stage, call the Property panel and set Starfield as the document class. I save the document as Starfield.fla.
- We create a new actionscript file, named Starfield.as. We will add here all the code to make the class work. We will make the class extend MovieClip because this is a Document Class. Every document class extends MovieClip.
package {
public class StarField extends MovieClip {
public function StarField() {
}
}
}
- Add the needed imports.
// all we need to import from flash libraries
import flash.display.MovieClip;
import flash.geom.Point;
import flash.events.Event;
import flash.filters.BlurFilter;
// all we need to import from Flint library
import org.flintparticles.displayObjects.Dot;
import org.flintparticles.actions.*;
import org.flintparticles.counters.*;
import org.flintparticles.emitters.*;
import org.flintparticles.initializers.*;
import org.flintparticles.zones.*;
- We start by creating the constructor. I usually don’t put code in here, but i wait for the object to be added to the stage, before creating all of it.
public function StarField() {
this.addEventListener(Event.ADDED_TO_STAGE, added);
}
- So we have to create a added function, that will manage all of the rest.
private function added(e:Event) {
// your code here…
}
- Now we got to add the control code in the added function, so please delete the “your code here” line and add the newly created code. We start by creating the emitter.
var emitter:BitmapEmitter = new BitmapEmitter();
- We will use a Steady counter, that will keep on creating particles continuosly.
emitter.setCounter( new Steady(20) );
- I will add a blur effect to have some sort of trail.
emitter.addFilter( new BlurFilter( 2, 2, 1 ) );
- We add the initializers. I will use dots for stars, make them change their birth color from 0xFFFFFFFF and 0xFF000FFF, position the stars on a line before they start moving, and give them a left handed direction.
emitter.addInitializer( new SharedImage( new Dot( 1 ) ) );
emitter.addInitializer( new ColorInit( 0xFFFFFFFF, 0xFF000FFF ) );
emitter.addInitializer( new Position( new LineZone(new Point(250, 0), new Point(250, 250))) );
emitter.addInitializer( new Velocity( new PointZone( new Point (-100, 0) ) ) );
- Now that all is set, i add actions, that will drive my particles. I tell the particles to move, and i limit their speed to 200, because i do not want them to move too quickly. Then i add a DeathZone, a zone in which the particles contained are set dead or safe (which is the case, and the second parameter determines if the zone if safe). If the particle run outside of the stage, are deleted.
emitter.addAction( new Move() );
emitter.addAction( new SpeedLimit(200) );
emitter.addAction( new DeathZone( new RectangleZone(0, 0, stage.stageWidth, stage.stageHeight), true) );
- So i will add the emitter to the stage, and make it start.
addChild( emitter );
emitter.start( );
emitter.runAhead(2);
- The class is done! Enjoy your particle starfield! This should be the result.
[download=4]
See you soon with other Flint related stuff!