Ultrashock Forums > Flash > ActionScript > UltraMath
particle effect

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
particle effect
Old 2003-09-06

Hi,
I'm struggling to work out how to generate a random number between -1 and 1. The point being to create a particle effect where particles could go one way or the other...
Any help would be much appreciated.
postbit arrow 2 comments | 307 views postbit arrow Reply: with Quote   
Registered User
silvertron is offline
seperator
Posts: 25
2002-10-22
seperator

Ultrashock Member Comments:
klaut klaut is offline 2003-09-07 #2 Old  
if you want to chose randomly between 1 or -1 :

ActionScript Code:
  1. var x = (Math.random()<0.5) ? 1 : -1;
  2.  
  3. trace(x);

if you want to chose a number inbetween the range of -1 and 1
ActionScript Code:
  1. var y = (Math.random()*2)-1 ;
  2.  
  3. trace(y);
Reply With Quote  
silvertron silvertron is offline 2003-09-07 #3 Old  
cheers for that
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: