Skip to main content
Known Participant
March 11, 2011
Answered

Display and play movie clips at random.

  • March 11, 2011
  • 1 reply
  • 385 views

Hi adepts!

I am trying to place 6 movie clips in an array and access them in a random manner so that when a button is pressed a movieclip appears and plays randomly.

All MCs are in frame one along with this code:

stop();
blk1._visible=false;
blk2._visible=false;
blk3._visible=false;
ppk1._visible=false;
ppk2._visible=false;
ppk3._visible=false;

storeCartons = new Array();
storeCartons = (blk1, blk2, blk3, ppk1, ppk2, ppk3);

startButton.onMouseUp = function(){
trace(myNumber);

myNumber=Math.floor(Math.random()*7)+ 0;
activeCarton = storeCartons(myNumber);
activeCarton._visible=true;

}
  how can I get this to work??

This topic has been closed for replies.
Correct answer nitesh836

Here is the updated code.

stop();
blk1._visible = false;
blk2._visible = false;
blk3._visible = false;
ppk1._visible = false;
ppk2._visible = false;
ppk3._visible = false;

storeCartons = new Array();
storeCartons = [blk1, blk2, blk3, ppk1, ppk2, ppk3];

startButton.onRelease = function() {
    myNumber = Math.floor(Math.random()*storeCartons.length);
    trace("myNumber "+myNumber);
    activeCarton = storeCartons[myNumber];
    activeCarton._visible = true;

};

1 reply

nitesh836Correct answer
Participant
March 12, 2011

Here is the updated code.

stop();
blk1._visible = false;
blk2._visible = false;
blk3._visible = false;
ppk1._visible = false;
ppk2._visible = false;
ppk3._visible = false;

storeCartons = new Array();
storeCartons = [blk1, blk2, blk3, ppk1, ppk2, ppk3];

startButton.onRelease = function() {
    myNumber = Math.floor(Math.random()*storeCartons.length);
    trace("myNumber "+myNumber);
    activeCarton = storeCartons[myNumber];
    activeCarton._visible = true;

};

jaswerlAuthor
Known Participant
March 14, 2011

Thank You nitesh836! This is a correct answer. I take it that button actions are

different than mouse actions. Where can I go to find out button actions?