mercredi 30 septembre 2015

Applying Drag, Snap Back Into Original Position To An Array

I am attempting to apply drag, snap back into position functions to an array with actionscript3. Here is the code so far:

var dragArray:Array = new Array;
dragArray.push(blockSmalla);
dragArray.push(blockSmallb);
dragArray.push(blockSmallc);
dragArray.push(blockSmalld);
dragArray.push(blockSmalle);

var startPosition:Point;
function drag(e:Event):void {
dragArray[i].startDrag();
startPosition = new Point( dragArray[i].x, dragArray[i].y);
}
function dragStop(e:Event):void {
dragArray[i].stopDrag();

dragArray[i].x = startPosition.x;
dragArray[i].y = startPosition.y;
startPosition = null;
}

for (var i:uint = 0; i < dragArray.length; i++) {
dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, drag);
dragArray[i].stage.addEventListener(MouseEvent.MOUSE_UP, dragStop);
}

Not working so far. Any suggestions?

Aucun commentaire:

Enregistrer un commentaire