7 Replies Latest reply on Feb 22, 2012 3:32 PM by kglad

    Help with existing AS2 code to rotate an object

    LuisRM Level 1

      I have an object that I want to rotate in 3D (letter "Y"). I have some code that I gathered and edited a bit, but right now it rotates at the top left as it's anchor. I'm trying to get it to rotate at the "crux" of the Y (absolute center), so it basically rotates in place.

       

      My second problem is the speed. Ideally it needs to rotate very fast then slow down and stop. Any thoughts on how to either clean up this code to make it work? I'm pretty new, so any help is appreciated. I could try it with just transforming the shape, but I'm trying to see if it can be cleaner with Actionscript. Thanks!

       

      Here is a link to the CS4 .fla file if that helps.

      http://board.flashkit.com/board/showthread.php?p=4296719#post4296719

       

       

      scaleDirect = -1;

      function dec2hex (dec)

      {

      if ( dec > 15 )

      {

      pos1 = hexChars.charAt( Math.floor ( dec / 16 ) );

      pos2 = hexChars.charAt( dec - ( pos1 * 16 ) );

      } else

      {

      pos1 = 0;

      pos2 = hexChars.charAt( dec );

      }

      hex = pos1 + pos2;

      return hex;

      }

      this.onEnterFrame = function()

      {

      letterMC._xscale += scaleDirect * Math.floor(1+ ( 101-Math.abs(letterMC._xscale) )/2 );

      if ( letterMC._xscale <= -100 || letterMC._xscale >= 100 )

      { scaleDirect *= -1; }

      }