I have a script that rotates 7 MCs around 7 individual points (like 7 moons orbiting around 7 of their own planets).
To add interest I made it so the speed and distance from the planet the moon orbits is random for each of the 7.
I also have tween class easing on the 7 MCs to scale up on rollover.
My issue is that it ends up very processor heavy and I would like to reduce the load it puts on the computer.
I realize the onEnterFrame is my culprit, but I do not know how to go about it any other way.
var radius = Math.random() * 10;
var degrees = Math.random() * 1000;
var radius2 = Math.random() * 10;
var degrees2 = Math.random() * 1000;
var radius3 = Math.random() * 10;
var degrees3 = Math.random() * 1000;
var radius4 = Math.random() * 10;
var degrees4 = Math.random() * 1000;
var radius5 = Math.random() * 10;
var degrees5 = Math.random() * 1000;
var radius6 = Math.random() * 10;
var degrees6 = Math.random() * 1000;
var radius7 = Math.random() * 10;
var degrees7 = Math.random() * 1000;
onEnterFrame = function (){
angle = degrees * (Math.PI/360);
degrees += Math.random() * 7 + 2;
angle2 = degrees2 * (Math.PI/360);
degrees2 += Math.random() * 7 + 2;
angle3 = degrees3 * (Math.PI/360);
degrees3 += Math.random() * 7 + 2;
angle4 = degrees4 * (Math.PI/360);
degrees4 += Math.random() * 7 + 2;
angle5 = degrees5 * (Math.PI/360);
degrees5 += Math.random() * 7 + 2;
angle6 = degrees6 * (Math.PI/360);
degrees6 += Math.random() * 7 + 2;
angle7 = degrees7 * (Math.PI/360);
degrees7 += Math.random() * 7 + 2;
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);
x3position = radius3 * Math.cos(angle3) * (2.5);
y3position = radius3 * Math.sin(angle3) * (2.2);
x4position = radius4 * Math.cos(angle4) * (2.5);
y4position = radius4 * Math.sin(angle4) * (2.2);
x5position = radius5 * Math.cos(angle5) * (2.5);
y5position = radius5 * Math.sin(angle5) * (2.2);
x6position = radius6 * Math.cos(angle6) * (2.5);
y6position = radius6 * Math.sin(angle6) * (2.2);
x7position = radius7 * Math.cos(angle7) * (2.5);
y7position = radius7 * Math.sin(angle7) * (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
sales_mc._x = x3position + Math.exp(Math.round(3)) + _root.sales_earth._x
sales_mc._y = y3position + Math.exp(Math.round(3)) + _root.sales_earth._y
other_mc._x = x4position + Math.exp(Math.round(3)) + _root.other_earth._x
other_mc._y = y4position + Math.exp(Math.round(3)) + _root.other_earth._y
nonProfit_mc._x = x5position + Math.exp(Math.round(3)) + _root.nonProfit_earth._x
nonProfit_mc._y = y5position + Math.exp(Math.round(3)) + _root.nonProfit_earth._y
business_mc._x = x6position + Math.exp(Math.round(3)) + _root.business_earth._x
business_mc._y = y6position + Math.exp(Math.round(3)) + _root.business_earth._y
retailers_mc._x = x7position + Math.exp(Math.round(3)) + _root.retailers_earth._x
retailers_mc._y = y7position + Math.exp(Math.round(3)) + _root.retailers_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, Elastic.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, Elastic.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, Elastic.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, Elastic.easeInOut, 120, 100, 1);
// scales down to orginal size on Roll Out
};
sales_mc.onRollOver = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(sales_mc, Elastic.easeInOut, 100, 120, 1);
// scales up to specified size on Roll Over
};
sales_mc.onRollOut = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(sales_mc, Elastic.easeInOut, 120, 100, 1);
// scales down to orginal size on Roll Out
};
other_mc.onRollOver = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(other_mc, Elastic.easeInOut, 100, 120, 1);
// scales up to specified size on Roll Over
};
other_mc.onRollOut = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(other_mc, Elastic.easeInOut, 120, 100, 1);
// scales down to orginal size on Roll Out
};
nonProfit_mc.onRollOver = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(nonProfit_mc, Elastic.easeInOut, 100, 120, 1);
// scales up to specified size on Roll Over
};
nonProfit_mc.onRollOut = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(nonProfit_mc, Elastic.easeInOut, 120, 100, 1);
// scales down to orginal size on Roll Out
};
business_mc.onRollOver = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(business_mc, Elastic.easeInOut, 100, 120, 1);
// scales up to specified size on Roll Over
};
business_mc.onRollOut = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(business_mc, Elastic.easeInOut, 120, 100, 1);
// scales down to orginal size on Roll Out
};
retailers_mc.onRollOver = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(retailers_mc, Elastic.easeInOut, 100, 120, 1);
// scales up to specified size on Roll Over
};
retailers_mc.onRollOut = function():Void {
// scaleT(mc, easeType, startSize, endSize, time) <-- parameters to enter below:
scaleT(retailers_mc, Elastic.easeInOut, 120, 100, 1);
// scales down to orginal size on Roll Out
};
Can anyone help me reduce the processing load of the script?