A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Dynamic dice?

Threaded View

  1. #1
    Title? Am I King or something?
    Join Date
    Jul 2009
    Location
    Ponyville, Happytown on the continent Nowhereland
    Posts
    26

    Dynamic dice?

    Hey, I'm trying to make a dice-rolling program that can change the amount of sides available, for a small demo. It's for a game I am developing just to see if I can, so I'm in no rush. This is my entire (and very short) source code:

    Code:
    stop();
    
    dieSides = sidesInput; 
    wepBonus = bonusInput;
    
    btnRoll.onRelease = function(){
    	die = Math.round(Math.random() * sidesInput);
                 die += wepBonus;
    } // end roll
    As you can see, I have a dynamic text field named "sidesInput" and "bonusInput". I make the variable "dieSides" equal to the text field "sidesInput", as well with "wepBonus" and "bonusInput".

    When I click the button "btnRoll", the text field "die" should become equal to a random number multiplied by "sidesInput" rounded to the nearest whole number, with the variable "wepBonus" added to the final result. In theory, this should work for me. But whenever I press "btnRoll" and start off the function that creates the output, all I get is an annoying "NaN" as the output.

    How can I fix this?
    Last edited by --Fusiox--; 11-13-2009 at 02:54 PM.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center