In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2012-4-30

Get Adobe Flash player
by colbrand 29 Apr 2012

    Talk

    colbrand at 29 Apr 2012 21:52
    Just a couple useful commands to exercise, and very hard way to stimulate dice roll :D
    Embed
/**
 * Copyright colbrand ( http://wonderfl.net/user/colbrand )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mB11
 */

package
{
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.display.Sprite;
    public class Dice extends Sprite{
    
    
    public var dice:Sprite;
    public var diceOutline:Sprite;
    public var rollNumber:int = 4;
    public var diceCircles:Sprite;
    public var rollString:TextField;
    
    
    
 

   
    
    public function Dice()
    {
        dice = new Sprite();
        diceOutline = new Sprite;
        diceCircles = new Sprite;
        rollString = new TextField;
        
        dice.graphics.beginFill(0xffffff);
        dice.graphics.drawRect(103,103,60,60);
        dice.graphics.endFill();
        
        
        diceOutline.graphics.beginFill(0x000000);
        diceOutline.graphics.drawRect(100,100,66,66);
        diceOutline.graphics.endFill();
        
        rollNumber = (Math.random()*6) + 1;
        
        rollString.text = "You Rolled " + rollNumber;
        
        
        
        
        switch (rollNumber)
        {
            case 1:
            diceCircles.graphics.beginFill(0x000000);
            diceCircles.graphics.drawCircle(133,133,7);
            diceCircles.graphics.endFill();
            break;
            
             case 2:
            diceCircles.graphics.beginFill(0x000000);
            diceCircles.graphics.drawCircle(113,113,7);
            diceCircles.graphics.drawCircle(153,153,7);
            diceCircles.graphics.endFill();
            break;
            
             case 3:
            diceCircles.graphics.beginFill(0x000000);
            diceCircles.graphics.drawCircle(113,113,7);
            diceCircles.graphics.drawCircle(133,133,7);
            diceCircles.graphics.drawCircle(153,153,7);
            diceCircles.graphics.endFill();
            break;
            
             case 4:
            diceCircles.graphics.beginFill(0x000000);
            diceCircles.graphics.drawCircle(113,113,7);
            diceCircles.graphics.drawCircle(113,153,7);
            diceCircles.graphics.drawCircle(153,113,7);
            diceCircles.graphics.drawCircle(153,153,7);
            diceCircles.graphics.endFill();
            break;
            
             case 5:
            diceCircles.graphics.beginFill(0x000000);
            diceCircles.graphics.drawCircle(113,113,7);
            diceCircles.graphics.drawCircle(113,153,7);
            diceCircles.graphics.drawCircle(153,113,7);
            diceCircles.graphics.drawCircle(153,153,7);
            diceCircles.graphics.drawCircle(133,133,7);
            diceCircles.graphics.endFill();
            break;
            
             case 6:
            diceCircles.graphics.beginFill(0x000000);
            diceCircles.graphics.drawCircle(113,113,7);
            diceCircles.graphics.drawCircle(113,153,7);
            diceCircles.graphics.drawCircle(153,113,7);
            diceCircles.graphics.drawCircle(153,153,7);
            diceCircles.graphics.drawCircle(113,133,7);
            diceCircles.graphics.drawCircle(153,133,7);
            diceCircles.graphics.endFill();
            break;
                
        }
 
           
    
  
               
        addChild(diceOutline);
        addChild(dice);
        addChild(diceCircles);
        addChild(rollString);
   
        
    }
    }
    
   

}