...

View Full Version : drag'n'drop problem



Kor
04-11-2005, 04:29 PM
Frankly, it is not really a d'n'd problem. I suspect is it is an array's manipulate, but I don't sense which is the problem.

I warn you that is (at the moment) a quite intricate code. If you are not a skilled and if you have not enough time to test (or if you don't like me ), don't test it...

I'll try to isolate my problem now. It is a puzzle. User should put the correct picture on the correct cell on a table. The drag'n'drop functions work ok. The final ideea is that on each moment (the final is the goal) there must be two arrays of values, cells with the correspondend pics superimposed.

In my code, the
function ver(cont,zz,drI){//set the array pairs picture/cell
is responsible of the adding/removing the elements on/from those arrays. If a picture is on a cell, add an extra element on each of those arrays. If switch, switch the elements on those arrays. If the picture is out of the pazzle's table, remove both elements from thoae arrays. I suspect that this function is wrong made, but I can't figured where I was wrong...

Unfortunately, when manipulate those pictures on/off the table, strange things occure. Test the code like that;

move pic0 over cell 0, than pic 1 over cell1. In this order. Check button, looks ok. Now move pic0 out of the table than move pic1 out of the table.In this order.Now, when checking the arrays (click the button) there is a pair of elements left, cell1 with pic1, even if normally should have been no elements left on both arrays. What do I do wrong? Example is on attachment.

Harry Armadillo
04-11-2005, 06:24 PM
You forgot to splice wPicId.

Kor
04-12-2005, 09:24 AM
Dear Sir, thank you very much, you have great eyes. Indeed, that seems to be the error. I was not able to see that, as I work for quite a time at this project and I wasn't able to detach myself from it...

Once again, million thanks. Consider the problem solved :thumbsup:

Kor
04-12-2005, 10:44 AM
nope... I am affraid that it was not enough. When, let's say, move pic0 on cell 0, pic1 on cell1 than move inside pic0 to cell 3 and pic1 to cell 4, the array is messed up again... Instead of correct cell3-pic0|cell4-pic1 it appears 4-1|1-1 :( That drives me crazy....

codegoboom
04-12-2005, 10:48 AM
Consider the problem solved :thumbsup:

Oops... how did they taste? :D

...the words

Kor
04-12-2005, 10:52 AM
sorry, I have not tested eneough... This project took me too much time and effort (even it looked easy at the begining) so that I fell I will leave it away, quit the job and apply for retirement....

Thare must be a stupid error somehow, but I am not able to get it... The splice() is not working ok, but I don't sense why... :(

codegoboom
04-12-2005, 12:36 PM
Yeah, I dragged and dropped... to notice that if an image is placed *under* another, it is incorrectly handled (but am too lazy to find out why). ;)

Kor
04-12-2005, 12:40 PM
this could be solved, but incorrect array building occures even when moving some pictures here and there without place them one on eachother... I guess I will restart coding the whole code as I simply can not sense what happens at this stage. I can not simply "exit above" the code and anylize it in an objective way...

codegoboom
04-12-2005, 12:44 PM
Geez, me either... enter the code, that is. :)

Harry Armadillo
04-12-2005, 02:14 PM
???

Once I added wPicId.splice(i,1) to the picture goes out of the table section, I've been able to move the image into and out of the table with out problem. I put multiple in one cell, multiple in two cells, and so on, and the arrays looks to be fine (I also have ver(...) run arata() at its end). Any particular sequence I should try?

Is there any reason you've used the three arrays? It seems it would be easier to use a single array, PicLocation[picNumber]=cellNumber (or null).

Harry Armadillo
04-12-2005, 02:41 PM
Spoke too soon...

Two flaws: block(e) run through whether you've been dragging or not. Meaning, if you drag/highlight and release the mouse button while hovering over an image, it counts as dropping into that cell and can double up the array. Cured by a simple if(!sDrag) return; at the beginning.

And, ver(cont,blah,drI): you are feeding it both the object that was dragged (cont) and the object that was mouse-upped (drI), testing wPicId[i] against drI and inserting according to cont. In the case of dragging a low number picture under a high number one, cont and drI don't match. Eliminate drI.

Kor
04-12-2005, 04:15 PM
thanx for the patience you have followed my code. I'll try your advices and let u know the progresses.

Harry Armadillo
04-17-2005, 05:28 AM
Anything ever happend with this?

I'm not certain this where you were going with your code, but the question of how to organize the data for a jigsaw puzzle kept bothering me. So I made one. It looks like your idea of a cell-data array and a picture-data array is a good way to go, I couldn't do it with just a single data structure.

If interested, take a look at my ugly Moz/Firefox-only attempt.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum