nex - you’re on the right track! most of that’s right on the money.
one thing … smls and bigs represent the scale, not the width and height, small but important difference.
m represents the clip which you attach each time the while loop is itererated. it’s just an easy way to refer to it. i could go:
this.attachMovie("sqr","s"+i,i);
this["s"+i]._x = this["s"+i].xx = this["s"+i].smlx = 80 * i;
...etc
but that looks like hell, is a lot more typing, and all that evaluation is hard on the processor. much better to assign the results of attachMovie to a variable, then use that to refer to the clip.
m.xx is used to contain where the clip would actually be if the position wasn’t rounded to the nearest 20th of a pixel.
for instance, say this code was looping over and over:
this._x += 2.326672;
the movie will move, rounding the result each time. here’s a comparison to show the difference:
with rounding without
0 0
2.35 2.326672
4.7 4.653344
7.05 6.980016
9.4 9.306688
11.75 11.63336
14.1 13.960032
16.45 16.286704
see how they get further and further apart? the solution is to add to an in between variable (which doesn’t round). you increment that variable, preserving the mathmatical integrity, and then make the _x equal that variable. that way the movie is always within .05 of where you want it to be. which, in flash, is as close as you can get.
xx is the holder variable, as is yy, as is ss. thus, they need to be initilised at the movie’s _x (or _y, or _xscale respectivly) position.
hmmm. did that make it clearer?
this._parent means: the movie that’s above me in the hierarchy. say i make a movie called ‘bigdaddy’ in _root, then make a movie called ‘child’ in ‘bigdaddy’. this._parent from ‘child’ refers to ‘bigdaddy’, this._parent from ‘bigdaddy’ refers to _root. it’s the actionscript equivilant to ‘…/’ for directory structures.
here’s a blow by blow of the clickaction method:
MovieClip.prototype.clickAction = function(){
i’m defining a function which will be method of the MovieClip object (just like play(), or gotoAndStop()). that means that all this code will be executed relative to the clip it’s called from. since we assign this function to an onRelease handler, that means it will be run relative to whatever movie you click on.
if(!this._parent.lock){
i store a variable name lock in the parent movie. it it’s true, it means that there’s already a movie in motion and we should wait for it to stop. so only proceed if it’s false.
this._parent.lock = 1;
ok, lock must have been false so we can go ahead. set lock to true to prevent this function from working if it’s called again in the meantime.
if(this._parent.frontPic == this){
i store the clip that is currently in front (big) in this._parent.frontPic. if that equals me (‘this’) it means we’re in front and should do the toBack action.
this._parent.frontPic = null;
if we’re here, it means that we were in front. since we won’t be shortly and nothing is coming up to the front, we’ll set the frontPic variable to null. that way we’ll know that there’s nothing up front next time the function is called.
**this.toBack();[/]
initiate the back actions.
}else{
else, if we’re not up front then we’re a little pic so we’ll need to call the toFront actions.
this.toFront();
initiate the to front actions
}
}
end if, end function.