Subject: RE: random number 2004-03-10 - By Jesse Warden
Back function getRandomNum(range){ return (Math.floor(Math.random() * range + 1)); }
function getPlusOrMinus(){ var result = getRandomNum(2); if(result == 1){ return (-1); }else if(result == 2){ return (1); } }
function getPlusZeroOrMinus(){ var result = getRandomNum(2); if(result == 1){ return (-1); }else if(result == 2){ return (0); }else if(result == 3){ return (1); } }
???
-- --Original Message-- -- From: Adrian McTaggart [mailto:AMacTaggart@(protected)] Sent: Wednesday, March 10, 2004 09:55 AM To: flashnewbie@(protected) Subject: [Flashnewbie] random number
If the following code: -- ---- ---- ---- ---- ---- ---- ---- ------ var valueY = Math.floor(Math.random() * (3)); -- ---- ---- ---- ---- ---- ---- ---- ------
generates a random number between 0 - 3 how can I change it so that the following results are obtained:
1) Generates 1 number either (+1, -1).
2) Generates 1 number either (+1, 0, -1).
TIA,
Adrian
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Supported by Fig Leaf Software -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Lower Prices for Certified Training! Check out new lower prices for Certified Macromedia Training from Fig Leaf Software. Expand your skill set with courses in ColdFusion, Flash, Rich Internet Applications and .NET in the new year. Fig Leaf Software provides the highest caliber instruction at our training centers in Washington D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location.
Get the details at http://training.figleaf.com/ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) For additional commands, e-mail: flashnewbie-help@(protected)
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Supported by Fig Leaf Software -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Lower Prices for Certified Training! Check out new lower prices for Certified Macromedia Training from Fig Leaf Software. Expand your skill set with courses in ColdFusion, Flash, Rich Internet Applications and .NET in the new year. Fig Leaf Software provides the highest caliber instruction at our training centers in Washington D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location.
Get the details at http://training.figleaf.com/ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) For additional commands, e-mail: flashnewbie-help@(protected)
|
|