11 Replies Latest reply on Mar 3, 2007 4:28 PM by Newsgroup_User

Flash Math ... planet revolve around sun

i have use a little math to make my planet move around in a circle ... but it is infront of t he sun .. i want to it to go behind the sun ... on the back half of the circle ... how can i do it
• 1. Re: Flash Math ... planet revolve around sun
use swapDepths() to repeatedly move your sun in front (and then behind) of your planet when your planet is in different portions of its orbit.
• 2. Re: Flash Math ... planet revolve around sun
yeah .. i think that should difinetly work .. but i still dont figure out how to identify .. point s on my orbit ... to return a value to triger a swapDepths();
• 3. Re: Flash Math ... planet revolve around sun
use the attach code option in this forum to copy and paste your code that causes your planet to move.
• 4. Re: Flash Math ... planet revolve around sun
var smile:MovieClip;
var onLand:MovieClip;
var jSpeed:Number = 1;
// the Maths
function circleX(distance:Number, angle:Number):Number {
return -distance*Math.sin(Math.PI*angle/1800);
}
function circleY(distance:Number, angle:Number):Number {
return -distance*Math.cos(Math.PI*angle/1800);
}
// main Function
brd.onMouseDown = function() {
trace(onLand._x);
trace(onLand._y);
};
smile.onEnterFrame = function() {
if (brdL.hitTest(onLand)) {
smile.swapDepths(this.getNextHighestDepth());
}
if (brdR.hitTest(onLand)) {
onLand.swapDepths(this.getNextHighestDepth());
}
//tf.text = (onLand._x+","+jSpeed+","+onLand._y+"--"+(100*Math.cos(Math.PI*5/20)));
jSpeed += (this._xmouse-(2));
onLand._x = (Stage.width/2)+circleX(280, -(jSpeed/8));
onLand._y = (Stage.height/2)+circleY(80, -(jSpeed/8));
smile._x = (Stage.width/2);
smile._y = (Stage.height/2);
var s = onLand._y/(Stage.height);
onLand._xscale = onLand._yscale=s*100;
};
// Smile is the sun and onLand is the planet
148.3;
280.6;
//
192.25;
253.45;
//
698.7;
292.4;
//
694.5;
315.7;
• 5. Re: Flash Math ... planet revolve around sun
var smile:MovieClip;
var onLand:MovieClip;
var jSpeed:Number = 1;
// the Maths
function circleX(distance:Number, angle:Number):Number {
return -distance*Math.sin(Math.PI*angle/1800);
}
function circleY(distance:Number, angle:Number):Number {
return -distance*Math.cos(Math.PI*angle/1800);
}
// main Function
brd.onMouseDown = function() {
trace(onLand._x);
trace(onLand._y);
};
smile.onEnterFrame = function() {
if (brdL.hitTest(onLand)) {
smile.swapDepths(this.getNextHighestDepth());
}
if (brdR.hitTest(onLand)) {
onLand.swapDepths(this.getNextHighestDepth());
}
//tf.text = (onLand._x+","+jSpeed+","+onLand._y+"--"+(100*Math.cos(Math.PI*5/20)));
jSpeed += (this._xmouse-(2));
onLand._x = (Stage.width/2)+circleX(280, -(jSpeed/8));
onLand._y = (Stage.height/2)+circleY(80, -(jSpeed/8));
smile._x = (Stage.width/2);
smile._y = (Stage.height/2);
var s = onLand._y/(Stage.height);
onLand._xscale = onLand._yscale=s*100;
};
// Smile is the sun and onLand is the planet
148.3;
280.6;
//
192.25;
253.45;
//
698.7;
292.4;
//
694.5;
315.7;
• 6. Re: Flash Math ... planet revolve around sun
brdL :MovieClip; brdR:MoiveClip ... these are at the edge of the stage .. on the side ....
• 7. Re: Flash Math ... planet revolve around sun
try:

• 8. Re: Flash Math ... planet revolve around sun
yes thanks ... ... i tried somthing like that ..but it just keep swaping Depths on the enterframe ...i stilll dont figure out how your alreadyChange variable work... but everything runs fine .........
• 9. Re: Flash Math ... planet revolve around sun
you're welcome. the code i used swaps depths when the plane of onLand's orbit first moves above smile and when it first moves below smile on each rotation.
• 10. Re: Flash Math ... planet revolve around sun
yes .. thanks again .. mi site is coming together slowly ...
• 11. Re: Flash Math ... planet revolve around sun
yes .. thanks again .. mi site is coming together slowly ...