A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: custom rotation...

  1. #1
    Junior Member
    Join Date
    Apr 2003
    Location
    vancouver, b.c. (canada)
    Posts
    6

    custom rotation...

    hi everyone... i'm have'n a bit of trouble with a custom graphic...

    imagine the recycle'n symbol ( three arrows in a circle ) ... well i'd like to rotate the graphic so that the ' arrow ' that was clicked is on top... and repeat for the other arrows indefinately ... i'm try'n to keep it simple but any ideas are welcome... thanks .. and take care...
    - live long and prosper -

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Call your arrows arrowA, arrowB and arrowC. Implement them as copies of the same arrow graphic movieclip and put them (rotated and positioned) in a container movie called recycle_mc.

    Arrow A should be in the 'home position' on the top. Arrow B should be the next arrow, clockwise.

    Make sure the arrows are named within the container movie symbol, and that the container movie is named on the stage. This is so that in the following script, references like recycle_mc.arrowA will work.

    This script should be attached to the frame where the recycle_mc first appears.

    code:

    // These 3 functions set the desired
    // angle for each arrow (dividing 360
    // into 3 slices) when you click on the arrow
    recycle_mc.arrowA.onPress = function()
    {
    recycle_mc.desiredAngle = 0;
    }

    recycle_mc.arrowB.onPress = function()
    {
    recycle_mc.desiredAngle = 240;
    }

    recycle_mc.arrowC.onPress = function()
    {
    recycle_mc.desiredAngle = 120;
    }

    // this function keeps the wheel spinning
    // until the desired arrow is on top

    recycle_mc.onEnterFrame = function()
    {
    // set desiredAngle to next 'slot' which
    // is higher than current _rotation, so that
    // we always rotate clockwise
    while (this.desiredAngle < this._rotation)
    {
    this.desiredAngle += 360;
    }
    // Insure we don't over-rotate
    while (this.desiredAngle > this._rotation+360)
    {
    this.desiredAngle -= 360;
    }
    var da = this.desiredAngle - this._rotation;
    this._rotation += da * .1;
    // use higher numbers (.2 .3 etc.)
    // for faster speeds
    }

    // this initializes the wheel
    recycle_mc.desiredAngle = 0;




    EDIT: Reversed the 120 and 240 after testing - see below.
    Last edited by jbum; 10-19-2004 at 02:26 AM.

  3. #3
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Attached is the above script, with an accompanying movie to test it.
    Attached Files Attached Files

  4. #4
    Junior Member
    Join Date
    Apr 2003
    Location
    vancouver, b.c. (canada)
    Posts
    6
    .. thank you my marvelous friend ( i hope i can call you a friend ) ... this works like a charm ( the code ) .. thanks again.. and i owe you one.. take care.. live long and prosper...
    - live long and prosper -

  5. #5
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Coolness - now just don't forget to recycle!

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