Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Question drag'n'drop problem

    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.
    Attached Files Attached Files
    Last edited by Kor; 04-11-2005 at 04:42 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You forgot to splice wPicId.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Unhappy nope...

    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....
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kor
    Consider the problem solved
    Oops... how did they taste?
    ...the words
    *this message will self destruct in n-seconds*

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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).
    *this message will self destruct in n-seconds*

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #9
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Geez, me either... enter the code, that is.
    *this message will self destruct in n-seconds*

  • #10
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ???

    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).

  • #11
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #12
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    thanx for the patience you have followed my code. I'll try your advices and let u know the progresses.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #13
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •