I’m making an ambient banner, of bubbles for my site…It’s randomly scrippted, the bubbles travel from bottom to top, then they pop…here is the AS i used:
numBubbles = 6;
for (i=2; i<numBubbles; i++){
bubbles.duplicateMovieClip("bubbles" add i, i+100);
}
//make it random
onClipEvent (load) {
function reset() {
//random alpha
this._alpha = random(100)+25
this._y = 120;
//random X loc
this._x = Math.floor(Math.random() * (580 - 20)) + 20;
//random speed
enemySpeed = random(6)+1;
this.gotoAndStop(1);
//random Y pop loc
pop = Math.floor(Math.random() * (60 - 20)) + 20;
//random bubble size
bubSize = Math.floor(Math.random() * (5 - 1)) + 1;
if(bubSize == 1) {
this._xscale = 100;
this._yscale = 100;
}
else if(bubSize == 2) {
this._xscale = 80;
this._yscale = 80;
}
else if(bubSize == 3) {
this._xscale = 60;
this._yscale = 60;
}
else if(bubSize == 4) {
this._xscale = 40;
this._yscale = 40;
}
}
reset();
}
//float
onClipEvent (enterFrame) {
//speed
this._y -= Math.round(enemySpeed);
//if statements
if (this._y <= 0) {
reset();
}
if (this._y <= pop) {
this.gotoAndPlay(2);
}
}
I have a pop sound on the second key frame of the bubble MC, the problem is when the bubble hits the pop Y position, it continues to make the pop noise until the function resets, i don’t know how to only make it play once…
here is the .fla