suziam
August 20th, 2007, 12:50 AM
Hi guys,
This has been driving me crazy for hours now and I haven't found much similar to it on the forum so here goes:
I have a grid of input boxes, and have instance named them box1, box2 etc all the way to box25.
I have a movie clip called fyi that i want to be dragged over these input boxes. if the mouse drags fyi over one of these boxes and releases the mouse button, i want that specific text box to say "FYI".
I thought creating a loop for this would be quicker, however it doesn't work. If i substitute the "boxName" for "box1", then it works in the box1 instance, however I want it to work in all 25 of them.
Here's the code:
var i:Number;
for (i = 1; i<26; i++) {
boxName = eval("box"+i);
_root.fyi.onRelease = function() {
if (_root.fyi.hitTest(_root.boxName)) {
_root.boxName.text = "FYI";
trace("hit!");
}
stopDrag();
_root.fyi._x = 1067;
_root.fyi._y = 387;
}
trace(i);
}
_root.fyi.onPress = function() {
startDrag(_root.fyi, true);
}
Cheers
This has been driving me crazy for hours now and I haven't found much similar to it on the forum so here goes:
I have a grid of input boxes, and have instance named them box1, box2 etc all the way to box25.
I have a movie clip called fyi that i want to be dragged over these input boxes. if the mouse drags fyi over one of these boxes and releases the mouse button, i want that specific text box to say "FYI".
I thought creating a loop for this would be quicker, however it doesn't work. If i substitute the "boxName" for "box1", then it works in the box1 instance, however I want it to work in all 25 of them.
Here's the code:
var i:Number;
for (i = 1; i<26; i++) {
boxName = eval("box"+i);
_root.fyi.onRelease = function() {
if (_root.fyi.hitTest(_root.boxName)) {
_root.boxName.text = "FYI";
trace("hit!");
}
stopDrag();
_root.fyi._x = 1067;
_root.fyi._y = 387;
}
trace(i);
}
_root.fyi.onPress = function() {
startDrag(_root.fyi, true);
}
Cheers