# Help with creating bubbles with Actionscript

**URL:** https://forum.kirupa.com/t/help-with-creating-bubbles-with-actionscript/225821
**Category:** flash
**Created:** [May 16, 2007, 1:33am UTC](https://forum.kirupa.com/t/help-with-creating-bubbles-with-actionscript/225821 "2007-05-16T01:33:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dwpegues](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dwpegues/32/18678_2.png) [@dwpegues](https://forum.kirupa.com/u/dwpegues)
#### Post date: [May 16, 2007, 1:33am UTC](https://forum.kirupa.com/t/help-with-creating-bubbles-with-actionscript/225821/1 "2007-05-16T01:33:28Z")

</div>

Hello there everyone.

I created bubbles using the snow 3.0 tutorial from here at kirupa. I slightly altered the code so it would be for bubbles on a canvas of 800x500.

The problem with the tutorial is that it is for snow moving downward on the y axis. for bubbles in the water, I need them going upward. Could someone please help me with which part of the code I need to alter so the bubbles will move up and not down? Also, I need the life of the bubble to last the length of the canvas.

Thank you

Code:

```
init = function () {

width = 800;
// pixels
height = 500;
// pixels
max_bubblesize = 10;
// pixels
bubbles = 75;
// quantity
for (i=0; i&lt;bubbles; i++) {

t = attachMovie("bubbles", "bubbles"+i, i);
t._alpha = 20+Math.random()*60;
t._x = -(width/2)+Math.random()*(1.5*width);
t._y = -(height/2)+Math.random()*(1.5*height);
t._xscale = t._yscale=50+Math.random()*(max_bubblesize*10);
t.k = 1+Math.random()*2;
t.wind = -1.5+Math.random()*(1.4*3);
t.onEnterFrame = mover;

}

};
mover = function() {

this._y += this.k;
this._x += this.wind;
if (this._y&gt;height+10) {

this._y = -20;

}
if (this._x&gt;width+20) {

this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;

} else if (this._x&lt;-20) {

this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;

}

}
init();
```
