# \[Flash8\] AS hogging CPU and/or slowing down my .swf

**URL:** <https://forum.kirupa.com/t/flash8-as-hogging-cpu-and-or-slowing-down-my-swf/209348>\
**Category:** flash\
**Created:** [December 7, 2006, 10:06pm UTC](https://forum.kirupa.com/t/flash8-as-hogging-cpu-and-or-slowing-down-my-swf/209348 "2006-12-07T22:06:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TylerNZ](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tylernz/32/415_2.png) [@TylerNZ](https://forum.kirupa.com/u/TylerNZ)\
**Post date:** [December 7, 2006, 10:06pm UTC](https://forum.kirupa.com/t/flash8-as-hogging-cpu-and-or-slowing-down-my-swf/209348/1 "2006-12-07T22:06:10Z")

</div>

Hi guys … I’ve been out of flash for a while and am making a come-back with 8. I’m creating a site and decided to have some moving grass at the bottom. I found this code online, however, when I add it to my movie, everything slow’s down. Here’s the details and code:

Details:

```auto
Flash 8 / AS 2.0
  Win XP SP2
  Firefox 2 (Doesn't seem to affect IE7 as much)

```

AS:

```auto
// Animated grass - Jim Bumgardner
//

DAMP = 0.9
TSPEED = 3 // turbulence (individual motion)
WSPEED = 0 // wind (common motion)

windx = 0; // Added these initializations for Flash Player 7
windy = 0;

MovieClip.prototype.drawBlade = function()
{
  this.clear();
  this.moveTo(-5,0);
  this.beginFill(this.clr, 20);
  this.curveTo(this.cx-5,this.cy,this.ex, this.ey);
  this.curveTo(this.cx+1,this.cy, 5, 0);
  this.lineTo(-5,0);
  this.endFill();
}

function bladeMove()
{
    this.vx1 += Math.random()*TSPEED-TSPEED/2 + windx;
    this.vy1 += Math.random()*TSPEED-TSPEED/2;
    this.vx2 += Math.random()*TSPEED-TSPEED/2 + windx;
    this.vy2 += Math.random()*TSPEED-TSPEED/2;
    this.vx1 *= DAMP; // damping
    this.vx2 *= DAMP;
    this.vy1 *= DAMP;
    this.vy2 *= DAMP;
    this.cx = this.cxR + this.vx1;
    this.cy = this.cyR + this.vy1;
    this.ex = this.exR + this.vx2 + windx;
    this.ey = this.eyR + this.vy2 + windy;
    this.drawBlade();
// Add these lines to travel horizontally
/*
    this._x -= 3;
    if (this._x < -5)
        this._x += Stage.width+10;
 */
}

function windBlow()
{
    windx += Math.random()*WSPEED - WSPEED/2;
    windx *= DAMP;
}

for (var i = 0; i <= 200; ++i) {
	var depth:Number = -1000;
    var mc = this.createEmptyMovieClip("fish_mc_"+i, depth-i);
    mc._x = 50+(i*5);
    mc._y = Stage.height-44;
    mc.clr = (0x20 + random(0x45)) << 8;
    mc.cx = mc.cxR = Math.random()*10-5;
    mc.cy = mc.cyR = -(3+Math.random()*40);
    mc.ex = mc.exR = Math.random()*10-5;
    mc.ey = mc.eyR = mc.cyR*2;
    mc.vx1 = 0; // Added these initializataions for Flash Player 7
    mc.vx2 = 0;
    mc.vy1 = 0;
    mc.vy2 = 0;
    mc.onEnterFrame = bladeMove;

}

this.onEnterFrame = windBlow;

```

Can anyone help? Maybe this code is a lil weak?  
Thanks!
