Adobe Animate HTML5 Canvas Random Position Change

How can I make movieclips randomly switch to each other's position?
movieclips name: harf_1, harf_2, harf_3...

How can I make movieclips randomly switch to each other's position?
movieclips name: harf_1, harf_2, harf_3...
// begin initialization
var harfA = [];
var positionA = [];
for(var i=1;i<=14;i++){ // assuming there are 14 harf movieclips
harfA.push(this["harf_"+i]);
positionA.push({x:harfA[i-1].x, y:harfA[i-1].y});
}
function shuffleF(a) {
for (var i = a.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
// end initialization
// whenever you want to shuffle the harf positions, call
function shuffle_harfF(){
shuffleF(harfA);
for(var i=0;i<harfA.length;i++){
harfA[i].x = positionA[i].x;
harfA[i].y = positionA[i].y
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.