# Rising Bubbles Flash AS3

**URL:** https://forum.kirupa.com/t/rising-bubbles-flash-as3/315042
**Category:** flash
**Created:** [October 15, 2010, 8:26pm UTC](https://forum.kirupa.com/t/rising-bubbles-flash-as3/315042 "2010-10-15T20:26:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![SereneAurora](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@SereneAurora](https://forum.kirupa.com/u/SereneAurora)
#### Post date: [October 15, 2010, 8:26pm UTC](https://forum.kirupa.com/t/rising-bubbles-flash-as3/315042/1 "2010-10-15T20:26:15Z")

</div>

Greetings,

I am in my first few weeks of learning Action Script 3, and I’m still busily working through tutorials and lessons to figure all this out. I came across a tutorial for a rising bubble effect that I would like to implement in a school assignment, but I’m struggling with it:

> **[DomRaider](http://the-dude.co.uk/tutorials/flash-tutorial-on-creating-random-animated-bubbles-as2/)**
>
> Are you looking for an expired domain name? YouDot offers over 80,000 domain names to boost your SEO and your traffic and to protect your brand.

Are the directions I followed, and an idea what I’m going for. I’ve modified the code a little bit from what was offered on the tutorial, adding notes to help myself along, and a couple of other small changes.

```auto
import flash.events.Event;

var bubbles = 100;
var thisBubble:Object;

for (var i = 0; i < bubbles; i++) {
thisBubble = this.addChild(new MC_bubble());
thisBubble.addEventListener(Event.ENTER_FRAME, displace);
thisBubble.yspeed = Math.random() * 2 + .2;

with (thisBubble) {
// Decides where on the X axis the bubbles will appear
x = Math.random() * stage.stageWidth;
// Decides where on the Y axis bubbles will appear
y = Math.random() * stage.stageHeight;
// Sets the size of the bubbles
width = height = 1 + Math.random() * 20;
// Opacity of the bubbles (??)
alpha = Math.random();
}
}

function displace(e:Event):void{
e.target.y -= e.target.yspeed;

if (e.target.y >= stage.stageWidth || e.target.x <= 0){
e.target.y = 400;
e.target.x = 10 + Math.random() * stage.stageWidth;
}
}

```

One modification I made was this line:

```auto

if (e.target.y = stage.stageWidth || e.target.x <= 0){

to 

if (e.target.y == stage.stageWidth || e.target.x <= 0){

```

Before I made this change, the bubbles would all go crazy at the bottom of this stage, and this line had a compiler error of:

**Warning: 1100: Assignment within conditional. Did you mean == instead of =?**

Hence the reason for the change, but I recognize my modification here could be part of my new issue.

The problem I’m having is that the bubbles are not looping. I’ve researched the syntax of my **for** statement, and tried to find some better information on my **function** , but I’m still a newbie.

Can anyone offer any assistance? I imagine it’s something simple. Thank you in advance.  
~Sarah
