Anonymous
public javascript v1 · immutablevar boxes:Array = ["box1", "box2", "box3", "box4", "box5"];for (var i:Number = 0; i<boxes.length; i++) { this[boxes[i]].onRelease = function() { var emptyPos:Array = new Array(); emptyPos.push(this._x, this._y); var dx:Number = this._x-empty._x; var dy:Number = this._y-empty._y; dist = Math.sqrt(dx*dx+dy*dy); if (dist<=51) { this._x = empty._x; this._y = empty._y; empty._x = emptyPos[0]; empty._y = emptyPos[1]; } };}