I just can't get the drag/drop coordinates thing.....

You must Login before you can answer or comment on any questions.

I have several images on the screen each with their own touchstart/touchmove/touchend functions. When the image is dragged and dropped somewhere, I just want to put the relative position (top and left) in a db for reload.

function populate() {
 
var db = Titanium.Database.open('mydb');
 
var imgRS = db.execute('SELECT myid,myimagename,mylabeltext,myxpos,myypos FROM mypics');
while (imgRS.isValidRow())
{
 //create the view, add the image and add the labeltext.
 //var mycenter = translate(imgRS.fieldByName('myxpos'),imgRS.fieldByName('myypos'));
 // push a container into the array.  This will hold the image and the label 
            myContainer.push(Titanium.UI.createView({
 
                width:200,
                height: 250,
                top:imgRS.fieldByName('myxpos'),
                left:imgRS.fieldByName('myypos'),
                borderWidth:3,
                borderColor:'#fff',
                backgroundColor: '#fff',
                databaseID:imgRS.fieldByName('myid')    
            }));
 
        var newcontaineridx = myContainer.length - 1;
        // add the new view to the current window.
        win.add(myContainer[newcontaineridx]);
 
 
            // make the event listener for move and scale
            var olt = Titanium.UI.create3DMatrix();
            var curX, curY;
 
            myContainer[newcontaineridx].addEventListener('touchstart', function(e) {
                curX = e.x;
                curY = e.y;
            });
            myContainer[newcontaineridx].addEventListener('touchmove', function(e) {
 
                var deltaX = e.x - curX,
                deltaY = e.y -curY;
 
                olt = olt.translate(deltaX,deltaY,0);
 
                e.source.animate({
                transform: olt,
                    duration: 100
                });
 
 
            });
            myContainer[newcontaineridx].addEventListener('touchend', function(e) {
 
// Now What???
// e.source.x?, e.source.top?, e.x?, e.top?.  Nothing seems to have the updated top/left value.         
 
    var db = Titanium.Database.open('mydb');
    db.execute('UPDATE MYPICS SET MYXPOS = ?, MYYPOS = ? WHERE MYID = ?',myleft,mytop,e.source.databaseID);
    db.close();
 
            });

Your Answer

This question has been locked and cannot accept new answers.