1. No Profile Picture
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Rep Power

    Question How can I program an orbit?

    I wish to creat a movie clip that will contain a number of "planets" (buttons) which will travel in an orbit. I am fairly new to ActionScript, so I don't know how to go about figuring out how to program this. Here's what I want to do:

    ONE: Have the planet/button travel an eliptical (or circular) orbit. In order to make the orbital effect more authentic, I would like to know how I can control the scale of the image depending on where it is on the orbit: say 0 degrees is North, 90 is East, 180 is south and 270 is West--the image scale is 100% at 180/south, 75% at East/90 and West/270, and 50% at North/0.

    TWO: When the cursor is over one of these planets (MouseOver) I want the orbital motion to pause (only while there is a MouseOver event happening).

    THREE: When one of the planets is clicked, I want all the planets to fly to the left and rest in a straight vertical formation, with the one that was clicked being at the top.

    If anyone has any good ideas about how I can acheive this ambitious project, I would greatly appreciate it.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Rep Power
    That really shouldn’t be too hard to do.
    Your “buttons” need to be movieclips so you can attach code to them either that or lplace the “buttons” inside of a movieclip. Place the movieclip on the stage and select it (make sure you give it an instance name) with the movieclip selected go to the actions window (expert mode) and type;

    OnClipEvent(enterFrame) {
    this._x += 5;
    this._xscale += 1;
    this._yscale += 1;
    if(this._x >= 400) {
    this.gotoAndPlay (2);

    with a set up like this you would have two frames and a movieclip in each frame. One would have the object on one side of the orbit the other would have the clip on the other side of the orbit. The code above moves the clip from left to right and upon reaching 400 pixels from the left side of the stage sends the play head to frame 2 where you would have the other clip and instead of second line reading this._x += 5; it would read
    this._x -= 5; and the >=400 value would be <= whatever the value is for the left hand position. You would also probably have to mirrored halves of this thing i.e. it goes half way across its orbit getting bigger as it goes and then switch to another clip or instance where it gets smaller as it continues its way across, though this last part may not be necessary. Something along these lines should do the orbit part of it.

    The flying buttons and rollovers should also be pretty straight forward.

    OnRollOver or onMouseOver you may have to define functions for these. I believe th rollover is just for buttons while the MouseOver is for movieclips.

    Anyway this should be pretty straight forward you may have to go to the reference books once or twice for the syntax.

IMN logo majestic logo threadwatch logo seochat tools logo