Hi
So I’m making a simple astronomy animation where mars is orbiting and leaving a trail behind it. When mars comes full circle, I want the trail to be erased and start over.
I have two questions:
What condition can I use to test to see if its the right time to restart the trail (the if _y<200 is just there for testing)
and
How can I restart the trail? Currently when I call makeTrail() a second time nothing happens.
var marsStart:Number = 0;
var marsSpeed:Number = 6;
var marsDistance:Number = 70 ; // Distance from mars to point it rotates around (orbit); radius of rotation.
// Set up the mars trail.
function makeTrail() {
_root.createEmptyMovieClip("marsTrail",2);
marsTrail.lineStyle(0,0x999999,50);
marsTrail.moveTo(mars._x,mars._y)
}
//create mars trail for the first time
makeTrail();
//create marstrail during animation
mars.onEnterFrame = function() {
this._x = orbit._x + Math.cos(marsStart/180*Math.PI)*marsDistance;
this._y = orbit._y + Math.sin(marsStart/180*Math.PI)*marsDistance;
marsStart += marsSpeed;
marsTrail.lineTo(mars._x,mars._y);
//Erase the mars trail
if (this._y < 200) {
marsTrail = null;
makeTrail();
}
// else{
// marsTrail._alpha = 50;
// }
}
var orbitStart:Number = 0;
var orbitSpeed:Number = 1;
var orbitDistance:Number = 150; // Distance form earth to center of mars orbit.
// Set up the orbit trail (the ring).
_root.createEmptyMovieClip("orbitTrail",3);
orbitTrail.lineStyle(0,0xdddddd,100);
orbitTrail.moveTo(orbit._x,orbit._y);
orbit.onEnterFrame = function() {
this._x = earth._x + Math.cos(orbitStart/180*Math.PI)*orbitDistance;
this._y = earth._y + Math.sin(orbitStart/180*Math.PI)*orbitDistance;
orbitStart += orbitSpeed;
orbitTrail.lineTo(orbit._x,orbit._y);
}
//Move the mars orbit path
morbitpath.onEnterFrame = function () {
this._x = orbit._x;
this._y = orbit._y;
}
Thanks. This is the first actionscript I’ve ever done and I need all the help I can get.
ps there are already movieclips on the stage called mars, morbitpath, earth, orbit