Playing random movieclips via timeline without repeating


i have 8 movie clips on main timeline. idea play first movie clip, once button clicked, go random frame 2-8 on timeline , play movielip on frame, sent frame 1 start process over. have figured out, don't want frames repeating until have been played. inside first movieclip button following actionscript attached. works except frames repeating before have played. can't see in script have gone wrong. please help!

 

 

var nums:array = new array();

1,2,3,4....

for(var i:uint=1; i<7; i++){

nums.push(i);

}

 

// shuffling array

function shuffle(a:array) {

    var p:int;

    var t:*;

    var ivar:int;

    (ivar = a.length-1; ivar>=0; ivar--) {

        p=math.floor((ivar+1)*math.random());

        t = a[ivar];

        a[ivar] = a[p];

        a[p] = t;

    }

}

 

// shuffle array

shuffle(nums);

 

// set controls button

var count:uint = 0;

 

boxbutton.addeventlistener(mouseevent.click, plyrndmmv);

 

function plyrndmmv(evt:mouseevent):void {

    movieclip(root).gotoandstop(nums[count]+2);

    count++;

    if(count == 8){

        shuffle(nums);

        count = 0;

    }

}

if code on frame 1, have problem.  if is, can use boolean prevent code repeatedly executing every time return frame.



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support