I have found several sites about this, but I can’t seem to figure out the answer and implement it into my code. I know it’s something simple somewhere, but I’m not a programmer by nature and I’m stuck.
I am trying to make a drag and drop template that will pull randomly from a text file or MySQL db later. I have hard coded this and it works fine, but there are 24 MCs in this app (12 goals and 12 movers) and I know there is a way to FOR LOOP through this.
I have the for loop set up and most of it works fine. Things are draggable, things stop dragging when released, text boxes are populated, the movers are scattered around the stage on startup. The problem is only the highest value of * is assigned. So the mover MC named mover12_mc is the only one that matches the goal. Actually all the draggable movers are named mover12_mc, but their text is correct. For now I am only matching numbers 1-1, 2-2, etc. Later it will be months or weekday names to be put in order. This hang up has caused me to stop several apps since I am sick of hard coding them.
I have narrowed it down to a parent child delegation instance, I think. I found a great tutorial on senocular.com, but as I said I still can’t fully match it to my code. Any suggestions would be greatly appreciated.
var moverXloc:Number = 200;
var goalXloc:Number = 50;
var goalBaseYloc:Number = 10;
var totalDiff:Number = 40;
var numBoxes:Number = 13; //one extra
var orderNums:Number = 1;
// loops through numBoxes variable and changes each text box to 1 + the base.
for (i=1; i<numBoxes; i++)
{
showMnums = eval(“mover”+i+"_mc.order_thing");
showMnums.text = i; // orderNums + i;
showGnums = eval(“goal”+i+"_mc.order_num");
showGnums.text = i; // orderNums + i;
moverName = eval(“mover”+i+"_mc");
moverName._x = 160 + Math.floor(Math.random()*(245-160+1));
moverName._y = Random(450); // they all start in random places
// functions for clicking each mover box
moverName.onPress = function () {
this.startDrag();
// each one is draggable, no problems here
}
goalName = eval(“goal”+i+"_mc");
//
moverName.onRelease = function () {
trace(moverName);
this.stopDrag();
if (moverName.hotSpot_mc.hitTest(goalName.hotSpot_mc)) {
moverName._x = goalXloc;
moverName._y = 10;
this.enabled = false;
// ALL the draggable things end up being named as the highest value of i.
// in this case they are all named mover12_mc
} // closes the IF loop
} // closes the eval-movername function
} // closes FOR loop
Thanks in advance.