flash on 2012-4-30
/**
* 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);
}
}
}