# AS2 background animation problem

**URL:** <https://forum.kirupa.com/t/as2-background-animation-problem/321022>\
**Category:** flash\
**Created:** [April 8, 2011, 3:47am UTC](https://forum.kirupa.com/t/as2-background-animation-problem/321022 "2011-04-08T03:47:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![danmc977](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@danmc977](https://forum.kirupa.com/u/danmc977)\
**Post date:** [April 8, 2011, 3:47am UTC](https://forum.kirupa.com/t/as2-background-animation-problem/321022/1 "2011-04-08T03:47:59Z")

</div>

Hey guys, ive got this code which creates a snow effect in the background, I just wanted to know if anyone knew how to turn it off when I go to another frame:

\*attachMovie(“snow\_background”, “snow\_background”, -16383, {\_x:400, \_y:300});  
for (var i = 0; i\<amount; i++) {  
thisSnow = this.attachMovie(“snow”, “snow”+i, i);  
with (thisSnow) {  
\_x = Math.random()\*800;  
\_y = Math.random()\*600;  
\_xscale = \_yscale=\_alpha=40+Math.random()\*60; }  
thisSnow.yspeed = Math.random()\*2+.2;  
thisSnow.onEnterFrame = function() {  
this.\_y += this.yspeed;  
if (this.\_y\>=600) {  
this.\_y = 0;  
this.\_x = 10+Math.random()\*800; }  
if (this.\_x\>=800 || this.\_x\<=0) {  
this.\_y = 0;  
this.\_x = 10+Math.random()_800;_ } } }

Ive tried:  
_snow.removeMovieClip()_ - doesnt work  
_var amount = 0_ - doesnt work  
Ive tried using if statements for when the game is over - doesnt work :cry3:  
Really stuck here.

Thanks  
Dan
