First comment: You do not have to delete the onMouseMove after each hit test, you can just have the hit tests listed in sequence.
I.E.
code:
//...SNIP...
this.onMouseMove = function(){
if(_root.pin.hitTest(_root.r_balloon)){
_root.r_balloon.gotoAndPlay("popped");
}
if(_root.pin.hitTest(_root.b_balloon)){
_root.b_balloon.gotoAndPlay("popped");
_root.b_balloon._visible = false;
}
if(_root.pin.hitTest(_root.g_balloon)){
_root.g_balloon.gotoAndPlay("popped");
}
if(_root.pin.hitTest(_root.p_balloon)){
_root.p_balloon.gotoAndPlay("popped");
}
}
}
//...SNIP...
Or you could use an if else chain here.
However, to make things easier, this is where you would use For loops and concatenation.
First, rename your balloon movie clips to:
balloon_0
balloon_1
balloon_2
balloon_3
Next you would set up a for loop and use concatenation to check each
of the balloons.
Concatenation is the operation of joining two character strings end to end or a string and variable.
In otherwords if you have this:
code:
var i = 0
_root["balloon_"+i]
is exactly like saying this:
code:
_root.balloon_0
You follow me so far?
Okay..here's the example:
code:
//...SNIP...
this.onMouseMove = function(){
//FOR LOOP CODE IS LIKE THIS
//for (starting number;repeat this until this condition is no longer true;how
//the number will increase. ++ in Flash means it will increase by 1 for //each time through the loop.
for (var i = 0;i <= 3;i++){
if(_root.pin.hitTest(_root["balloon_"+i])){
_root["balloon_"+i].gotoAndPlay("popped");
}
}
}
//...SNIP...




Reply With Quote