AS/function question

I’m really trying to do this one on my own without coming here for too much help :slight_smile:

I have an array that creates 7 mc clips with names.
I’m trying to make each one of those peices clickable.
When clicked each peice will slide over to the far left “barrier_mc” and stop.
Actually not true, the one closest to the “barrier_mc” will stop at the barrier and from then on each piece will stop when it hits the one beside it (kinda like a 7 car fender-bender). This isnt the problem im trying to work through right now, although i will in the near future. So if anyone can lend a hand on that :slight_smile:

What im trying to figure out is the array that creates the mc’s names them like the following “” infoBar"+i+"_mc"". What im trying to do is call that in a function so that i dont have to type in each of the 7 mc names manual I.E (infoBar0_mc) you’ll see my function at the bottem in the "function pieceStop"of the pasted code.

any help will be greatly appreciated.


var list:Array = ["piece1", "piece2", "piece3", "piece4", "piece5", "piece6", "piece7"];
var startingX:Number = list_mc._x;
var bottom:Number = 950;
var direction:String;
var spacing:Number = 70;
for (var i = 0; i<list.length; ++i) {
var name:String = "infoBar"+i+"_mc";
var x:Number = i*spacing;
_root.list_mc.attachMovie("infoBar", name, i);
_root.list_mc[name]._x = x;
_root.list_mc[name].moonName_txt.text = list*;
trace(" infoBar"+i+"_mc");
}
//
//
//
//
MovieClip.prototype.easeTo = function(tx, ty) {
this.onEnterFrame = function() {
//speed of tween
this._x = tx-(tx-this._x)/2;
this._y = ty-(ty-this._y)/2;
if (_root.list_mc.hitTest(_root.barrier_mc)) {
trace("barrier_hit");
pieceStop();
}
//
if (Math.abs(this._x-tx)<4 && Math.abs(this._y-ty)<1) {
this._x = tx;
this._y = ty;
delete this.onEnterFrame;
}
};
};
function pieceStop() {
_root.infoBar0_mc.stop;
list_mc.infoBar0_mc._alpha = 50;
delete _root.list_mc.onEnterFrame;
}

edit:

and the button code that triggers the mc to slide t the left is


on (release) {
 this.easeTo(-100);
}