Hi, i have an assignment for my AS 3.0 class that im struggling to finish. You enter in how many dice you want to roll (1-4) then you click the button below the dice to drop the dice down. You do that for hoever many dice you entered in that your going to roll, then you hit roll. Pretty simple. I need help getting it so that lets say the user entered in 2 for how many dice he will roll, after he clicks 2 of the buttons to add the dice below, the rest of the buttons and available dice disappear so they are not click able or visible. Im very very new to programming so bear with me. Thanks! zipped file is attached.
Heres my cod:
var myInput:Number;
roll_btn.addEventListener(MouseEvent.CLICK, onClick);
reset_btn.addEventListener(MouseEvent.CLICK, resetClick);
button1_btn.addEventListener(MouseEvent.CLICK, showDice1);
button2_btn.addEventListener(MouseEvent.CLICK, showDice2);
button3_btn.addEventListener(MouseEvent.CLICK, showDice3);
button4_btn.addEventListener(MouseEvent.CLICK, showDice4);
button5_btn.addEventListener(MouseEvent.CLICK, showDice5);
button6_btn.addEventListener(MouseEvent.CLICK, showDice6);
myInput = Number(input_txt.text);
/switch (myInput)
{
case 1
}/
function onClick(event:MouseEvent):void
{
dice1_mc.gotoAndStop(Math.ceil(Math.random() * 6));
dice2_mc.gotoAndStop(Math.ceil(Math.random() * 10));
dice3_mc.gotoAndStop(Math.ceil(Math.random() * 8));
dice4_mc.gotoAndStop(Math.ceil(Math.random() * 4));
dice5_mc.gotoAndStop(Math.ceil(Math.random() * 12));
dice6_mc.gotoAndStop(Math.ceil(Math.random() * 20));
}
function resetClick(event:MouseEvent):void
{
button1_btn.visible = true;
dice1_mc.x = 83.40;
dice1_mc.y = 107.90;
button2_btn.visible = true;
dice2_mc.x = 165.30;
dice2_mc.y = 115.15;
button3_btn.visible = true;
dice3_mc.x = 237.35;
dice3_mc.y = 109.95;
button4_btn.visible = true;
dice4_mc.x = 318.90;
dice4_mc.y = 110.05;
button5_btn.visible = true;
dice5_mc.x = 399.70;
dice5_mc.y = 107.10;
button6_btn.visible = true;
dice6_mc.x = 480.05;
dice6_mc.y = 106.85;
}
function showDice1(event:MouseEvent):void
{
button1_btn.visible = false;
dice1_mc.x = 78;
dice1_mc.y = 275;
}
function showDice2(event:MouseEvent):void
{
button2_btn.visible = false;
dice2_mc.x = 165;
dice2_mc.y = 275;
}
function showDice3(event:MouseEvent):void
{
button3_btn.visible = false;
dice3_mc.x = 235;
dice3_mc.y = 275;
}
function showDice4(event:MouseEvent):void
{
button4_btn.visible = false;
dice4_mc.x = 319;
dice4_mc.y = 275;
}
function showDice5(event:MouseEvent):void
{
button5_btn.visible = false;
dice5_mc.x = 396;
dice5_mc.y = 275;
}
function showDice6(event:MouseEvent):void
{
button6_btn.visible = false;
dice6_mc.x = 477;
dice6_mc.y = 275;
}