PDA

View Full Version : Shouldn't this work? Array related question...



blah-de-blah
August 12th, 2003, 11:12 PM
So i'm trying to figure out how to drop a dragged object onto any box, but no where else. So i tried using this:


targArray = new Array();
targArray = [theTarget1, theTarget2, theTarget3, theTarget4, theTarget5, theTarget6, theTarget7, theTarget8, theTarget9];


theTarget1 and stuff are all instance names of the box. Then later on, i use:

if (eval(this._droptarget) == targArray) {

So doesn't that mean if i drop the target anywhere on the instances then do whatever is next??

The bad thing is, it doesn't seem to be working :-\ Anyone know whY? thanks! I'm helping someone out for this problem, but i got stuck myself :P

ahmed
August 13th, 2003, 12:38 AM
http://www.kirupaforum.com/forums/showthread.php?threadid=31327

blah-de-blah
August 13th, 2003, 01:04 AM
for (i=0; i<=targArray.length; i++) {
if (eval(this._droptarget) == targArray) {
//dowhatever
}
}


Do you mean something like that? because it seems like i should be replacing targArray in the second line with something else... :-\

EDIT: btw, what does the break do?? thanks!

grandsp5
August 13th, 2003, 02:58 PM
break goes out of the loop. it stops the loop from running.

blah-de-blah
August 14th, 2003, 12:49 AM
o ok thanks, but how should i change the code? because it seems wrong and not working :-\

kode
August 14th, 2003, 01:26 AM
if (eval(this._droptarget) == targArray[i]) {

blah-de-blah
August 14th, 2003, 01:30 AM
oo yea its workin now, thanks :)

kode
August 14th, 2003, 01:32 AM
No problem. ;)