Click to See Complete Forum and Search --> : This one drives me loco...
This drag-n-drop script... I've got it to work fine and all, but I'm working on a function (function mixMolecule()) to mix the molecules selected. I'm including the .zip file because the page uses images to drag-n-drop. Anyone know how to work this one out? I've figured out how to find the ID of one layerNameArray[i], and then I can assing var j = 1 to get molecule45 to get layerNameArray[j]. layerNameArray[i] where i = 0 will equal molecule0. It's the if() function that catches me then... if(layerName==layerNameArray[i] && testObj) { alert() } This results in no problem, however, what can I do for.. if(layerName==layerNameArray[i] && layerName==layerNameArray[j] && testObj) { alert() } This one will not alert, no matter what images are dropped into the central box. Any help would really be appreciated. Thanks,
Jona
khalidali63
02-11-2003, 12:37 PM
If you drop 1,4,5-9I image in the central box it will call the empty alert message
cheers
Khalid
Yes, but I only want it to alert when two of the images (molecule0 and molecule45) are in the central box. How do I do that?
*BUMP*
Hey, I fixed the code up a little to make it where I know layerName returns the layer's name, but how can I make two variables work through so I know if BOTH molecule0 and molecule45 are in the box???
Thanks,
*BUMP*
A lot of people post on here... please answer me, someone! This is literally driving me nuts! LOL! Charles? Dave? Anyone?
khalidali63
02-12-2003, 12:03 PM
Create a variable say
var flag = false;
when either of the 2 images is dropped in the box then set the flag to true
then check for the falg to be true if it is then you know that the other image is already in the box.
cheers
Khalid
That sounds good... I was thinking I may have to count how many times the mouse was clicked, but then I realize that they may click something/somewhere else first... :(
That will possibly work... let me think this out... *thinks*
So I just set the variable to true if molecule45 is in the box, and I know by layerName that molecule0 is in the box? That's what I was looking for, I just couldn't think of a way to get another variable to equal the next layerName. I think I got it now... I'll post again if it doesn't work.
Thanks
Oh, BTW, I noticed that I do not need to check for testObj, just for layerName==layerNameArray[i]...
*BUMP* This post keeps getting on page 2!
OK, I tried it, but how do I make "flag" equal layerName 2? Where layerName is the actual layer clicked on, but "flag" would equal the second layer clicked on.
Please help! This is seriously driving me crazy! LOL!
khalidali63
02-13-2003, 07:54 PM
You can do this.
When you drop either of the images first in the boxdo this onmousedoun create a l'll function that checks for the image that generated the event or which event was selected.YOu already have this code only need to create another function.
say something like this
molecule0 and molecule45
if(!flag && (layerName=="molecule0" || layerName=="molecule45"){
//set the flag to be true
flag=true;
}else{
//your message here
}
hope this helps
cheers
Khalid
OK, that sounds good. I'll try it when I get back on my other computer. I'm at a friend's house tonight... Thanks. If anyone has any other ideas, polease post on here. Thanks!