Hi
I’m really new to this actionscript game and even newer to actionscript 3, but i desperately need some help with something my brain just doesn’t want to grasp. I am trying to change some open source code for a particle effect that makes some really nice snow. The source code uses a coded circle to generate the snowey effect, however i want to have a customised snowflake so i want to change the code so that it uses a movieclip to generate the snow.
Here is the .as code as i have changed it (i commented out the original):
package
{
import flash.display.*;
import flash.geom.Rectangle;
import flash.filters.BlurFilter;
public class SnowFlake extends Sprite
{
// the x and y velocity of the snowflake
public var xVel:Number;
public var yVel:Number;
// the size of the snowflake
public var size:Number ;
// and the limits of the screen
public var screenArea:Rectangle;
//adds displayobject for particle
//public var clip:DisplayObject;
public function SnowFlake(screenarea:Rectangle, spriteclass : Class/*, targetclip : DisplayObjectContainer*/)
{
// instantiate a new particle graphic
screenArea = new spriteclass();
// and add it to the stage
//targetclip.addChild(clip);
// FIRST THINGS FIRST!
// let's draw a little dot.
//graphics.lineStyle(3,0xffffff);
//graphics.moveTo(0,0);
//graphics.lineTo(0.2,0.2);
//graphics.beginFill(0xffffff,1);
//graphics.drawCircle(0,0,1.5);
//graphics.endFill();
And here is the .fla stuff:
import flash.events.Event;
import flash.geom.Rectangle;
// first make an array to put all our snowflakes in
var snowFlakes : Array = new Array();
// and decide the maxium number of flakes we want
var numFlakes : uint = 200;
// and define a rectangle to store the screen dimensions in.
var screenArea:Rectangle = new Rectangle(0,0,900,675);
// start listening for an ENTER_FRAME event (the equivalent
// of the AS2 onEnterFrame function)
addEventListener(Event.ENTER_FRAME, frameLoop);
// and define the function that is called on an ENTER_FRAME event
function frameLoop(e:Event)
{
var snowflake : SnowFlake;
// if we don't have the maximum number of flakes...
if(snowFlakes.length<numFlakes)
{
// then make a new one!
snowflake = new SnowFlake(screenArea, spark);
// add it to the array of snowflakes
snowFlakes.push(snowflake);
// and add it to the stage
//addChild(snowflake);
}
I keep getting the error “TypeError: Error #1034: Type Coercion failed: cannot convert spark@1cd66179 to flash.geom.Rectangle.
at SnowFlake$iinit()
at SnowStorm_fla::MainTimeline/frameLoop()”
…and i have no idea what this means…
Please can someone help me??