Change speed of random motion

i was wondering if it was possible to change the speed of the random motion. i was using Suprabeener’s AS for flash MX. thanks for any help.


i read over the AS and figured out what i was doing wrong, thanks anyway.

can you tell me what you did to get the speed increased?

look through the script for

 this.speed = Math.random()*4+2;

the “4” is the max speed, and the “2” is the min speed, and it will randomly pick a number between the 2 so if your script looked like this

    this.speed = Math.random()*80+1;  

it could go anywhere form extremely fadst to extremely slow, just play around with the numbers and see what you come up with, also yoiu may want to check out this script inside of all that too…

  	if (getTimer()-this.t>1000) {

the “1000” is the time it sits between movements. the higher the number the longer it will sit still.

hope this helped you out.


one thing you didnt include, and some people may need this info:
Math.random()*15+5 will return values between 5 & 15, BUT it will return a lot more than 10 different values, because MX will take it out to like 8 decimel places (ie 7.927001568 or something, I forget how many places exactly it goes to, but it is a bunch). In order to aviod this you can use Math.round() which will round using conventional methods. Or you can use Math.floor() which will always round down or Math.ceiling() which will always round up. Useful if you want random vales within a range but dont want to end up with a bunch that are only a few 0.0001 off of eachother. Just an FYI.


*Originally posted by Ryall *
*Math.random()15+5 will return values between 5 & 15
Between 5 and 19.9999999999999999 actually :slight_smile:

pom :asian: