Flint Particle System Forum - Beginner problems with the snow tutorial custom class 2010-06-13T06:44:25+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Beginner problems with the snow tutorial custom class http://flintparticles.org/forum/comments.php?DiscussionID=77&Focus=357#Comment_357 2008-09-04T00:45:24+01:00 2010-06-13T06:44:25+01:00 meckanism http://flintparticles.org/forum/account.php?u=61 Hey all, Well i started reading the beginner tutorial (snow) to get more acquainted with flint. Writing the code in the first frame works well, also the document class works fine, the problem is ...
Well i started reading the beginner tutorial (snow) to get more acquainted with flint.
Writing the code in the first frame works well, also the document class works fine, the problem is for the custom class.
I must admit i'm a novice to actionscripting, i began with AS3 ( :( ), so my knowledge overall is lousy.
So i did exactly has said on the tutorial for the custom class and a couple of compiler errors showed up. I've been searching all over the forum and all over the web and couldn't find anything related. My goal is to do a smoke emitter like the one on the tutorials section that tweens along with another movieclip. I want to use custom classes to do all that also because i want to get more skilled on OOP.So for the snow tutorial i did the following:

1) new as3 .fla

2) on frame one added this:
Import Snowfall;

var emitter:Snowfall = new Snowfall();
addChild( DisplayObject( emitter.renderer ) );
emitter.start();
emitter.runAhead( 10 );

3) created a new .as file named Snowfall on the same directory as the .fla and wrote the class like this:

package
{
import flash.geom.Point;
import org.flintparticles.actions.*;
import org.flintparticles.counters.*;
import org.flintparticles.displayObjects.Dot;
import org.flintparticles.emitters.Emitter;
import org.flintparticles.initializers.*;
import org.flintparticles.renderers.*;
import org.flintparticles.zones.*;

class Snowfall extends Emitter
{
renderer = new DisplayObjectRenderer();

counter = new Steady( 50 );

addInitializer( new ImageClass( Dot, 2 ) );
addInitializer( new Position( new LineZone( new Point( -5, -5 ), new Point( 505, -5 ) ) ) );
addInitializer( new Velocity( new PointZone( new Point( 0, 50 ) ) ) );
addInitializer( new ScaleInit( 0.75, 1.5 ) );

addAction( new Move() );
addAction( new DeathOffStage() );
addAction( new RandomDrift( 10, 10 ) );
}
}

when i compile it, it gives me these errors:

Description: 1120: Access of undefined property renderer. source: renderer = new DisplayObjectRenderer();

Description: 1120: Access of undefined property counter. source: counter = new Steady( 50 );

Description: 1180: Call to a possibly undefined method addInitializer. ( for all the addInitializer methods )

Description: 1180: Call to a possibly undefined method addAction. ( for all the addAction methods)

I can see that the class is not well formed because there is no constructor and also the variables for the renderer and counter do not have the "var" prefix.Also nor the class or function or even variables have public or private set. I've tried and changed all i could think was wrong and still it doesn't compile right.

Hope anyone can help this poor newbie out :P
Sorry for the poor English.
Thanks in advance for any help.

meck]]>
Beginner problems with the snow tutorial custom class http://flintparticles.org/forum/comments.php?DiscussionID=77&Focus=358#Comment_358 2008-09-04T10:11:19+01:00 2010-06-13T06:44:25+01:00 Richard http://flintparticles.org/forum/account.php?u=1 Sorry, there were a couple of errors in the script. Don't know how I made the mistake copying it into the page. It's fixed now. Beginner problems with the snow tutorial custom class http://flintparticles.org/forum/comments.php?DiscussionID=77&Focus=359#Comment_359 2008-09-04T12:37:28+01:00 2010-06-13T06:44:25+01:00 meckanism http://flintparticles.org/forum/account.php?u=61 Nice it's working now, thanks.