Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums Does anyone know the actionscript code for RANDOM
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 03-07-2004, 02:16 PM #1 Matsko New Member   Join Date: Mar 2004 Location: Toronto Posts: 28 Does anyone know the actionscript code for RANDOM Hey Does anyone know how to make a random actionscript. For Example if you are playing a game where you need to guess a number that is random. Then there would need to be a line of code where the actionscript generates a random number. Does anyone know how to do that??
 03-07-2004, 03:56 PM #2 nthpixel Registered User   Join Date: Feb 2004 Location: Honolulu Posts: 186 Math.random() generates a number between 0 and 1. If you want a random number between 0 and 100, it would be Math.random()*100. Between -50 and 50 would be Math.random()*100 - 50. You get the idea.
 03-07-2004, 04:07 PM #3 Matsko New Member   Join Date: Mar 2004 Location: Toronto Posts: 28 ok good it works, but do you know how to make it equal to a whole number with no decimal places?
 03-07-2004, 04:22 PM #4 oaker was here.     Join Date: Jan 2003 Location: ATL Posts: 539 Math.floor(random()*100); For example: The following code returns a value of 10: Math.floor(10.5); __________________ Later, oaker www.oaker.com
 03-07-2004, 04:46 PM #5 Matsko New Member   Join Date: Mar 2004 Location: Toronto Posts: 28 OK, thanx it worked

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

All times are GMT. The time now is 05:03 AM.

///