hello everyone,
i am making a little web game for a project in my uni using canvas + JS + KineticJS library.
Although, i am stuck a bit...

ok, there is an object Game, which represents the game itself as you can tell. The game includes Tiles, which is the basic entity. (game is kinda of a puzzle)
so... there is this code:

Code:
this.play = function() {
    			while (turn < tiles.length) {
    			this.nextRound();
    		}
    	}
simple enough. If there are more tiles not played, go to next round...

Code:
this.nextRound = function() {
    			//lock = true;
    			this.active = this.tiles.shift();
    			this.gameLayer.add(this.active.image);
    			this.gameLayer.draw();
    			turn++;
    		
    			active.image.on("dragend", function(){
    				that.active.image.draggable(false);
    				//lock = false;
    			});
    			//while (lock == true) {continue;}
    	}
and this is the code for the round. We fetch the next availabe tile, we make it our active tile, increase the rounds, and dynamically add the on dragend property (KineticJS stuff). It basically says that when someone has dragged the tile, after the drag ends, make the image undraggable. Logical, since after the drag ends the tile will be in the puzzle, so we don't want to drag it anymore. (in this section there is more code, checking the vadility of the drag etc... but i have left it out since it is irrelevant to the question)

Ok the thing is the commented code...
I want the function to "wait" until the drag is done... like to have a var lock = true... and until it becomes false... DO NOT go to next round... Although i am having trouble implementing that....

any ideas?
thank you