Dice simulation in Exel

  1. #1
    madmikejt12 is offline Dedicated Member

    Dice simulation in Exel

    hi, i want to put a dice simulation in an exel document so that when the user presses a button labled "roll now" or similar, a random number (1-6) apears on a dice face. Does anyone know how to da this?
    I was trying to do it using notepad (using HTML) and opening it with I.E but it didnt work.
    Will i need Flash MX or a similar program to do this?

    Any help will be helpfull


  2. #2
    madmikejt12 is offline Dedicated Member
    i have the dice pics that i want to use

  3. #3
    madmikejt12 is offline Dedicated Member
    i am using macromedia flash now and i have this code:
    button.onPress
    var face0=new Image()
    face0.src="d1.gif"
    var face1=new Image()
    face1.src="d2.gif"
    var face2=new Image()
    face2.src="d3.gif"
    var face3=new Image()
    face3.src="d4.gif"
    var face4=new Image()
    face4.src="d5.gif"
    var face5=new Image()
    face5.src="d6.gif"
    <img src="d1.gif" name="d1.gif">
    Form
    <input type="button"<img src="dice_w.gif" name="button"> value="Roll dice!" onClick="random(0,*6))">
    Form
    <script>
    function
    //create a random integer between 0 and 6
    function randRange(min:1, max:6):6 {
    var randomNum:Number = Math.round(Math.random()*(max-min))+min;
    return randomNum;
    }

    document.images["dice"].src=eval("face"+randomdice+".src")




    i also have these errors:
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 14: Syntax error.
    <img src="d1.gif" name="d1.gif">

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 16: Syntax error.
    <input type="button"<img src="dice_w.gif" name="button"> value="Roll dice!" onClick="random(0,*6))">

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 21: Function name expected
    function randRange(min:1, max:6):6 {

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 26: Syntax error.
    document.images["dice"].src=eval("face"+randomdice+".src")

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 16: Type mismatch in assignment statement: found String where Boolean is required.
    <input type="button"<img src="dice_w.gif" name="button"> value="Roll dice!" onClick="random(0,*6))">

    Total ActionScript Errors: 5 Reported Errors: 5

  4. #4
    madmikejt12 is offline Dedicated Member
    d1.gif-d6.gif are the dice sides (numbered 1-6) do i need the file path linking them?
    it DID look like this:
    var face0=new Image()
    face0.src="C:\Documents and Settings\Owner\My Documents\My Pictures\Dice\d1.gif"
    var face1=new Image()
    face1.src="C:\Documents and Settings\Owner\My Documents\My Pictures\Dice\d2.gif"
    var face2=new Image()
    face2.src="C:\Documents and Settings\Owner\My Documents\My Pictures\Dice\d3.gif"
    var face3=new Image()
    face3.src="C:\Documents and Settings\Owner\My Documents\My Pictures\Dice\d4.gif"
    var face4=new Image()
    face4.src="C:\Documents and Settings\Owner\My Documents\My Pictures\Dice\d5.gif"
    var face5=new Image()
    face5.src="C:\Documents and Settings\Owner\My Documents\My Pictures\Dice\d6.gif"
    </script>

    i have tried to fix these errors but i have tried what seems to be everything!!!!

    (i want the dice for my sister because she is teaching in primary and she is making a game on exel and she wants a dice to randomly spin) even if she has to open it up seperatley... that would be better than nothing

  5. #5
    madmikejt12 is offline Dedicated Member
    ok, done the dice using HTML and JavaScript, is there any way of adding this into excel?
    or converting an excel document to html??
    or if that is not possible, how do i make it stay on top of other windows?

    here is what i used to do the dice:
    You load this first:
    <html>
    <head>

    </head>
    <body>

    <SCRIPT language="JavaScript1.2">
    window.open ("dice.html",
    "mywindow","menubar=0,resizable=1,width=150,height =150");

    </script>
    </body>
    </html>
    that opens this:
    <html>
    <HEAD>

    <html>
    <b><font color="red" size="2" face="Arial Black">Click on the dice to roll:</font></b><font face="Arial Black">
    </font>
    <p>
    <a href="dice.html">
    <img border="0" src="dice_t.gif" width="38" height="38">
    </a>
    </p>
    </html>
    <SCRIPT LANGUAGE="JavaScript">

    <!-- Begin
    function getRandomNum(lbound, ubound) {
    return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
    }
    // End -->
    </script>
    </HEAD>

    <BODY>
    <html>
    <body bgcolor="cyan" onload="" window.onblur="self.focus()">


    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    document.write("Move ");
    document.write(getRandomNum(1,7));
    document.write(" Space(s)");
    // End -->
    </script>
    </body>
    </html>
    but in a smaller window with no scroll bar, adress bar ect

    im nearly there now PLEASE HELP!!!!

+ Reply to Thread