# Particles: help!

**URL:** https://forum.kirupa.com/t/particles-help/262388
**Category:** flash
**Created:** [June 5, 2008, 3:45pm UTC](https://forum.kirupa.com/t/particles-help/262388 "2008-06-05T15:45:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Carin](https://avatars.discourse-cdn.com/v4/letter/c/b4bc9f/32.png) [@Carin](https://forum.kirupa.com/u/Carin)
#### Post date: [June 5, 2008, 3:45pm UTC](https://forum.kirupa.com/t/particles-help/262388/1 "2008-06-05T15:45:19Z")

</div>

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&lt;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??

---

<div class="post-metadata">

### Author: ![Alex\_Lexcuk](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Lexcuk](https://forum.kirupa.com/u/Alex_Lexcuk)
#### Post date: [June 6, 2008, 7:38am UTC](https://forum.kirupa.com/t/particles-help/262388/2 "2008-06-06T07:38:38Z")

</div>

```auto

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

import fl.motion.*

//Function with two tweens
var arr_mc:Array = new Array();
var tween_rain:Array = new Array();
var j:Number=0;
var pcs:Number=100;
var ID:Number=0;

function rain_creator():void {
	j++;
	if (j==pcs || j<=0) {
		clearInterval(ID);
	}
	arr_mc[j] =new rain();
	addChild(arr_mc[j]);
	arr_mc[j].x=Math.random()*500;
	arr_mc[j].scaleX=arr_mc[j].scaleY=0.01+Math.random()*0.1;
	
	arr_mc[j].tm=13-(arr_mc[j].scaleX*110)
	  
            arr_mc[j].rotation+=Math.random()*360;

	tween_rain[j]=new Tween(arr_mc[j],"y",Regular.easeInOut,-20, 400,arr_mc[j].tm,true);
	tween_rain[j].looping = true;
}
ID=setInterval(rain_creator,200);

```

[http://kind-armadillo.pochta.ru/FlaAC3/rain\_ac3.swf](http://kind-armadillo.pochta.ru/FlaAC3/rain_ac3.swf)  
[http://kind-armadillo.pochta.ru/FlaAC3/rain\_ac3.rar](http://kind-armadillo.pochta.ru/FlaAC3/rain_ac3.rar)

[http://kind-armadillo.pochta.ru/FlaAC3/Mod\_rain\_ac3.swf](http://kind-armadillo.pochta.ru/FlaAC3/Mod_rain_ac3.swf)  
[http://kind-armadillo.pochta.ru/FlaAC3/mod\_rain\_ac3.rar](http://kind-armadillo.pochta.ru/FlaAC3/mod_rain_ac3.rar)

[http://kind-armadillo.pochta.ru/fla/deciduous.rar](http://kind-armadillo.pochta.ru/fla/deciduous.rar)  
[http://kind-armadillo.pochta.ru/fla/deciduous.swf](http://kind-armadillo.pochta.ru/fla/deciduous.swf)
