I’m reposting this in a less convoluted form.
All I want to do is prevent more than one instance of the Bonus movieclip from being on screen at the same time. Since Bonuses are randomly generated, though, this poses a problem, as sometimes the calculation wants to make more than one at once.
So, I thought that a bonusTest variable could control this.
- if bonusTest = false, then it stops checking to see if it should create a Bonus, and no more are created.
- Once the Bonus is shot and removed, bonusTest = true, so that another one can appear.
But… it doesn’t work at all. Here’s all my Bonus code, what could be wrong?
// Bonus variable
bonusTest = true;
// Bonus creation
createBonus = function (x, y) {
bonusTest = false;
var bon = this.attachMovie("bonuslink", "Bonus", 102);
bonus._x = mf(mr()*400);
bonus._y = -80;
bonus.rate = random(3)+1;
bonus.onEnterFrame = bonus.ymove;
bonus.onRollOver = bonus.cursorColourOn;
bonus.onRollOut = bonus.onDragOut=bonus.cursorColourOff;
bonus.onPress = bonus.getShotI;
return bonus;
};
// shooting
MovieClip.prototype.getShotI = function() {
bonusTest = true;
this.cursorColourOff();
removeMovieClip(this);
};
// Make stuff!
this.onEnterFrame = function() {
iFreq = mf(mr()*100);
if (bonusTest=true) {
if (iFreq == 99) {
createBonus();
}
}
};
Yep, well, it doesn’t work. The Bonuses just keep on getting created like crazy and bonusTest is never checked.
Well, I’ll keep plugging away at it, but any tips are appreciated
- wobbly