The strange behaviour I have not been able to figure out, is that when I add a particular set of movie clips sometimes they appear and sometimes they do not.
I am building a game that uses “paddles” on screen to bounce balls around. Every level you get another paddle to play with. My code is as follows:
for (i=0; i < level; i++) {//add a paddleElement for each level of the game
trace("time to add a new paddle!");
var p:paddleElement = new paddleElement();
p.x = 650;
addChild(p);
trace(p+p.name+" just got added at depth "+this.getChildIndex(p));
p.y = paddleY;// paddleY is a defined constant.
p.x=500 + 160 * i;// make space between each paddleElement
paddles.push(p);// track how many paddleElements there are
}
The trace commands return as you would expect. The second one always returns something like [object paddleElement]instance324 just got added at depth 23
The thing that I can’t figure out is that sometimes when I get to the next level the paddles just dont’ appear. But then if I restart the game maybe they work for that level but not for the next. It seems that they don’t appear about half the time.
paddleElement is class that extends MovieClip
Can anyone see where I am going wrong?
Any advice would be greatly appreciated.
Thanks!