vendredi 19 février 2016

as3 prevent random frame label from being selected twice in a row

I wrote a small actionscript that basically tells a movie clip to go to and play a random frame listed within an array. Here is the code:

function getRandomLabel(): String {

    var labels: Array = new Array("e1", "e2", "e3");
    var index: Number = Math.floor(Math.random() * labels.length);
    return labels[index];
}
mc.gotoAndStop(getRandomLabel());

The problem I am trying to resolve is to prevent that same random frame label from being selected twice in a row. Any suggestions?

Aucun commentaire:

Enregistrer un commentaire