I'm trying to call a class to my main flash file in as3.
my class:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Snow extends MovieClip
{
private var flakesVector:Vector.<MovieClip> = new Vector.<MovieClip>();
private var timer:Timer = new Timer(2000);
public function Snow(speed:int = 3, flakesNumber = 100 ):void
{
for(var i:int = 0; i < flakesNumber; i++)
{
var flake:Snowflake = new Snowflake();
flake.vel = (Math.random() * speed) + 0.5;
flake.xSpeed = Math.floor(Math.random() * (0.5 - -0.5 + 1)) + -0.5;
flake.scaleX = (Math.random() * 1) + 0.3;
flake.scaleY = flake.scaleX;
flake.x = Math.random() * stage.stageWidth;
flake.y = Math.random() * stage.stageHeight;
addChild(flake);
flakesVector.push(flake);
}
addEventListener(Event.ENTER_FRAME, fall);
timer.addEventListener(TimerEvent.TIMER, changeMovement);
timer.start();
}
private function fall(e:Event):void
{
for(var i:int = 0; i < flakesVector.length; i++)
{
flakesVector[i].x += flakesVector[i].xSpeed;
flakesVector[i].y += flakesVector[i].vel;
if(flakesVector[i].y > stage.stageHeight)
{
flakesVector[i].x = Math.random() * stage.stageWidth;
flakesVector[i].y = -flakesVector[i].height;
}
}
}
private function changeMovement(e:TimerEvent):void
{
for(var i:int = 0; i < flakesVector.length; i++)
{
flakesVector[i].xSpeed *= -1;
}
}
}
}
And in my main fla i try to call it like this:
import classes.Snow;
var Snowy:Snow = new Snow();
addChild(Snowy);
But when i try to do it if i dont give any instance name to my snowflake movieclip i get "Cannot acess a property or method of a null object reference" and if i name my instance snowflake i get the error "type was not found or was not a compile-time constant: Snowflake"
What am I doing wrong?
Thank you.
EDIT:
but if i call the class document as Snow I get a lot of errors: any suggestion?