A Flash Developer Resource Site

Results 1 to 20 of 24

Thread: using AS to rotate a mc?

Hybrid View

  1. #1
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    notalower - your correction makes sense. You want to keep spinning in the same direction, but the rate of change in the spin comes down.

    Now to answer your last question, how to stop at a particular spot...

    Lemme noodle on this one...

    [edit]

    Mebbe something like this? This won't look all that natural, but it does what you described.

    I'm assuming the stopping position is _rotation == 0.

    code:

    // set this to slowest (final) speed
    _root.mc.minRate = 1;
    // set this to control the initial acceleration
    _root.mc.deccel = 0.5;
    _root.mc.curRate = 20;

    _root.mc.onEnterFrame=function()
    {
    // slow down until we hit a speed of 1
    if (this.curRate > this.minRate)
    {
    this.curRate -= this.deccel;
    }
    this._rotation += this.curRate;
    // are we there yet?
    if (Math.round(this._rotation) == 0)
    {
    // yep, we're there.
    this._rotation = 0;
    delete this.onEnterFrame;
    }
    }

    Last edited by jbum; 09-28-2004 at 12:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center