# Multiple values for Math.random

**URL:** <https://forum.kirupa.com/t/multiple-values-for-math-random/265482>\
**Category:** flash\
**Created:** [July 9, 2008, 2:25pm UTC](https://forum.kirupa.com/t/multiple-values-for-math-random/265482 "2008-07-09T14:25:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maroneyi](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Maroneyi](https://forum.kirupa.com/u/Maroneyi)\
**Post date:** [July 9, 2008, 2:25pm UTC](https://forum.kirupa.com/t/multiple-values-for-math-random/265482/1 "2008-07-09T14:25:03Z")

</div>

Hello,  
I am using Math.random to dynamically change the orbit speed/distance of a movie clip around a point (a second, empty movie clip).  
All is well with that.  
My issue is that I would like also have another random orbiting movie clip which orbits around it’s own separate point.

The problem is that both instances choose the same value for Math.random.  
What can I do so that they both choose different values?

Here is my AS:

```auto

var radius = Math.random()*10;
var degrees = Math.random()*1000;

var helper = Math.random(1000);

onEnterFrame = function (){
angle = degrees * (Math.PI/360);
degrees += Math.random()*3;

xposition = radius * Math.cos(angle) *(2.5);
yposition = radius * Math.sin(angle) *(2.2);

government_mc._x = xposition + Math.exp(Math.round(3)) + _root.government_earth._x
government_mc._y = yposition + Math.exp(Math.round(3)) + _root.government_earth._y

teachers_mc._x = xposition + Math.exp(Math.round(3)) + _root.teachers_earth._x
teachers_mc._y = yposition + Math.exp(Math.round(3)) + _root.teachers_earth._y

}

// Import the needed classes:
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Setup the Tween Function
function scaleT(mc, easeType, startSize, endSize, time):Void {
    var scaleTween = new Tween(mc, "_xscale", easeType, startSize, endSize, time, true);
    var scaleTween = new Tween(mc, "_yscale", easeType, startSize, endSize, time, true);
    scaleTween.onMotionFinished = function() {
        delete scaleTween;
        // trace("scaleTween finished and deleted"); // optional trace call
    };
}
//
// Setup the button codes
// yourButton_btn = your button instance
// yourMC = your mc instance you wish to scale
//
government_mc.onRollOver = function():Void {
    // scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
    scaleT(government_mc, Strong.easeInOut, 100, 120, 1);
    // scales up to specified size on Roll Over
};
government_mc.onRollOut = function():Void {
    // scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
    scaleT(government_mc, Strong.easeInOut, 120, 100, 1);
    // scales down to orginal size on Roll Out
};

teachers_mc.onRollOver = function():Void {
    // scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
    scaleT(teachers_mc, Strong.easeInOut, 100, 120, 1);
    // scales up to specified size on Roll Over
};
teachers_mc.onRollOut = function():Void {
    // scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
    scaleT(teachers_mc, Strong.easeInOut, 120, 100, 1);
    // scales down to orginal size on Roll Out
};

```

Any help or links would be greatly appreciated.  
-Ian

---

<div class="post-metadata">

**Author:** ![Maroneyi](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Maroneyi](https://forum.kirupa.com/u/Maroneyi)\
**Post date:** [July 9, 2008, 2:50pm UTC](https://forum.kirupa.com/t/multiple-values-for-math-random/265482/2 "2008-07-09T14:50:16Z")

</div>

For anyone interested:

```auto

var radius = Math.random() * 10;
var degrees = Math.random() * 1000;

var radius2 = Math.random() * 10;
var degrees2 = Math.random() * 1000;

var helper = Math.random(1000);

onEnterFrame = function (){
angle = degrees * (Math.PI/360);
degrees += Math.random() * 3;

angle2 = degrees2 * (Math.PI/360);
degrees2 += Math.random() * 3;

xposition = radius * Math.cos(angle) * (2.5);
yposition = radius * Math.sin(angle) * (2.2);

x2position = radius2 * Math.cos(angle2) * (2.5);
y2position = radius2 * Math.sin(angle2) * (2.2);

government_mc._x = xposition + Math.exp(Math.round(3)) + _root.government_earth._x
government_mc._y = yposition + Math.exp(Math.round(3)) + _root.government_earth._y

teachers_mc._x = x2position + Math.exp(Math.round(3)) + _root.teachers_earth._x
teachers_mc._y = y2position + Math.exp(Math.round(3)) + _root.teachers_earth._y

}

// Import the needed classes:
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Setup the Tween Function
function scaleT(mc, easeType, startSize, endSize, time):Void {
    var scaleTween = new Tween(mc, "_xscale", easeType, startSize, endSize, time, true);
    var scaleTween = new Tween(mc, "_yscale", easeType, startSize, endSize, time, true);
    scaleTween.onMotionFinished = function() {
        delete scaleTween;
        // trace("scaleTween finished and deleted"); // optional trace call
    };
}
//
// Setup the button codes
// yourButton_btn = your button instance
// yourMC = your mc instance you wish to scale
//
government_mc.onRollOver = function():Void {
    // scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
    scaleT(government_mc, Strong.easeInOut, 100, 120, 1);
    // scales up to specified size on Roll Over
};
government_mc.onRollOut = function():Void {
    // scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
    scaleT(government_mc, Strong.easeInOut, 120, 100, 1);
    // scales down to orginal size on Roll Out
};

teachers_mc.onRollOver = function():Void {
    // scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
    scaleT(teachers_mc, Strong.easeInOut, 100, 120, 1);
    // scales up to specified size on Roll Over
};
teachers_mc.onRollOut = function():Void {
    // scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
    scaleT(teachers_mc, Strong.easeInOut, 120, 100, 1);
    // scales down to orginal size on Roll Out
};

```
