Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with my basic activescript code

    My code is suppose to create 2 random numbers (for 2 dice), then create the correct media clip from the library and put it into a 2 containers on the screen.
    It only works 9/10 time, such as it mayl display dice 2 and 5 and the trace will be 3 and 2. Please can anybody see whats wrong. My codeing skills are very basic, thank.

    Code:
     	var rollresult1:int = 1 + Math.random()*6
    	var rollresult2:int = 1 + Math.random()*6
    	var rollresulttotal:int = rollresult1 + rollresult2
    
    
    	if  (rollresult1 == 1) 
    	{var dice11_mc:DICE1 = new DICE1();
    	Dice1_container_mc.addChild(dice11_mc);
    	}
    	else if  (rollresult1 == 2) 
    	{var dice12_mc:DICE2 = new DICE2();
    	Dice1_container_mc.addChild(dice12_mc);
    	}   
    	else if  (rollresult1 == 3) 
    	{var dice13_mc:DICE3 = new DICE3();
    	Dice1_container_mc.addChild(dice13_mc);
    	} 
    	else if  (rollresult1 == 4) 
    	{var dice14_mc:DICE4 = new DICE4();
    	Dice1_container_mc.addChild(dice14_mc);
    	}   
    	else if  (rollresult1 == 5) 
    	{var dice15_mc:DICE5 = new DICE5();
    	Dice1_container_mc.addChild(dice15_mc);
    	} 
    	else if  (rollresult1 == 6) 
    	{var dice16_mc:DICE6 = new DICE6();
    	Dice1_container_mc.addChild(dice16_mc);
    	}
    
    
    		if  (rollresult2 == 1) 
    		{var dice21_mc:DICE1 = new DICE1();
    		Dice1_container_mc.addChild(dice21_mc);
    		}
    		else if  (rollresult2 == 2) 
    		{var dice22_mc:DICE2 = new DICE2();
    		Dice1_container_mc.addChild(dice22_mc);
    		}   
    		else if  (rollresult2 == 3) 
    		{var dice23_mc:DICE3 = new DICE3();
    		Dice2_container_mc.addChild(dice23_mc);
    		} 
    		else if  (rollresult2 == 4) 
    		{var dice24_mc:DICE4 = new DICE4();
    		Dice2_container_mc.addChild(dice24_mc);
    		}   
    		else if  (rollresult2 == 5) 
    		{var dice25_mc:DICE5 = new DICE5();
    		Dice2_container_mc.addChild(dice25_mc);
    		} 
    		else if  (rollresult2 == 6) 
    		{var dice26_mc:DICE6 = new DICE6();
    		Dice2_container_mc.addChild(dice26_mc);
    		}
    
    
    
    trace(rollresult1, rollresult2, rollresulttotal)
    stop()

  • #2
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    oops sorry, should have check my code a few more times

    container1 in the second bit of code.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •