A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Rotation at a given rotation point in AS

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Location
    Asstown
    Posts
    107

    Rotation at a given rotation point in AS

    Hey ya'll.
    I was wondering on exactly how would you make an MC rotate with a given rotation center, using AS, obviously. I'd like to know the math behind it, please.
    Using _rotation would make it rotate around the mc's center... i'd like to make it rotate around another center, one defined...
    What's a siggy?
    /oh...

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Ordinarily, I would design the movie so that it's center (the crosshairs) corresponds to the pivot point for rotation. However, assuming that you want to perform different rotations, you can try the following.

    Let's say mc is the movie you want to rotate. Place mc inside another movieclip (mc_parent) and position it such that it's position relative to 0,0 is the rotation point you want. Then rotate mc_parent. So you'd do something like this:

    Code:
    createEmptyMovieClip("mc_parent", 0);
    mc_parent.attachMovieClip("mc","mc",1);
    
    mc._x = -30; // position relative to mc_parent's center (0,0)
    mc._y = 10;
    
    // position parent movie where you want it on the screen
    mc_parent._x = 100;
    mc_parent._y = 110;
    
    // rotate parent movie...
    
    mc_parent._rotation += 45;
    Note that to change the rotation point, you will have to change the location of mc inside mc_parent, and that this will change the location onscreen, unless you also change the location of mc_parent to adjust.

    For example, if you add 10 to mc._x, you will need to subtract 10 from mc_parent._x. Here's a routine to change the rotation point for mc:

    Code:
    MovieClip.prototype.changeRP = function(dx,dy)
    {
      this._x += dx;
      this._y += dy;
      this._parent -= dx;
      this._parent -= dy;
    }
    
    // adjust mc's rotation point:
    
    mc.changeRP( 30, 45);

  3. #3
    Senior Member
    Join Date
    Feb 2003
    Location
    Asstown
    Posts
    107
    interesting... i thought there would be more math into it... :-P
    thanks a lot!
    What's a siggy?
    /oh...

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