Var problem

Commenta 4th July , 2009
I want to create a new variable in an mc i just made. I tried an onLoad function but that doesnt seem to do anything.

ActionScript Code:
_root.attachMovie('mcBrick', 'brick'+i,_root.getNextHighestDepth()); _root['brick'+i]._x = 15+(i-brickRow*7)*75; _root['brick'+i]._y = 10+brickRow*20; //This onLoad function doesnt work =/ _root['brick'+i].onLoad = function() {     var hits:Number = 1;     trace(hits); } _root['brick'+i].onEnterFrame = function() {     if(this.hitTest(_root.mcBall)) {         //Therefore this doesnt happen...         this.hits--;         ballYSpeed *= -1;         _root.score += 10;         if(this.hits < 1) {             //So it doesnt remove.             this.removeMovieClip();             _root.brickAmt --;         }     } }

As you can see i traced hits but it returned "undefined".

Im sure its just something small i am missing but even so, i am confused as to why the onLoad isnt working…

Thanks for all help in advance.

Original post by crosshair

Lascia un Commento