SimpleSpriteRotation

by bradsedito
♥0 | Line 60 | Modified 2011-07-24 10:05:42 | MIT License
play

ActionScript3 source code

/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rq57
 */




package 
{
    import flash.display.Sprite;
    import flash.events.*;
    import com.greensock.*;
    import com.greensock.easing.*;
    
    public class SimpleSpriteRotation extends Sprite 
    {
        public function SimpleSpriteRotation() 
        {
            addEventListener(Event.ENTER_FRAME, loop);
            const SW:Number = new Number( stage.stageWidth  );
            const SH:Number = new Number( stage.stageHeight );
            var shape1:Sprite = new Sprite();
            var shape2:Sprite = new Sprite();
            var shape3:Sprite = new Sprite();
            var shape4:Sprite = new Sprite();
            
            shape1.graphics.beginFill( 0x131413 );
            shape1.graphics.drawCircle( 20, 0, 50);
            shape1.graphics.endFill();
            shape1.blendMode = "invert";
            addChild(shape1);

            shape2.graphics.beginFill( 0x333333 );
            shape2.graphics.drawCircle( 0, 20, 50);
            shape2.graphics.endFill();
            shape2.blendMode = "invert";
            addChild(shape2);
            
            shape3.graphics.beginFill( 0x131413 );
            shape3.graphics.drawCircle( 20, 0, 50);
            shape3.graphics.endFill();
            shape3.blendMode = "invert";
            addChild(shape3);

            shape4.graphics.beginFill( 0x333333 );
            shape4.graphics.drawCircle( 0, 20, 50);
            shape4.graphics.endFill();
            shape4.blendMode = "invert";
            addChild(shape4);

//                shape1.x = SW/2;    shape1.y = SH/2;
//                shape1.x = SW/2;    shape1.y = SH/2;
//                shape2.x = SW/2;    shape2.y = SH/2;
//                shape2.x = SW/2;    shape2.y = SH/2;
//                shape3.x = SW/2;    shape3.y = SH/2;
//                shape3.x = SW/2;    shape3.y = SH/2;
//                shape4.x = SW/2;    shape4.y = SH/2;
//                shape4.x = SW/2;    shape4.y = SH/2;

            function loop(event:Event):void 
            {
                var MainTL:TimelineMax = new TimelineMax({repeat:10 ,timeScale:1,yoyo:true});
                MainTL.append
                    (
                        TweenMax.to(shape1, 1, {rotationZ:(shape1.rotationZ)++, ease:Quad.easeInOut})
                    );
                MainTL.append
                    (
                        TweenMax.to(shape2, 1, {rotationZ:shape2.rotationZ++, ease:Quad.easeInOut})
                    );
                MainTL.append
                    (
                        TweenMax.to(shape3, 1, {rotationZ:shape3.rotationZ--, ease:Quad.easeInOut})
                    );
                MainTL.append
                    (
                        TweenMax.to(shape4, 1, {rotationZ:shape4.rotationZ--, ease:Quad.easeInOut})
                    );

//               shape1.rotationZ += ( Math.cos(45*Math.PI/180) )*15;     
//               shape2.rotationZ -= ( Math.cos(45*Math.PI/180) )*15;     
//               shape3.rotationZ += ( Math.cos(45*Math.PI/180) )*15;     
//               shape4.rotationZ -= ( Math.cos(45*Math.PI/180) )*15;                    
//               arr:Array = new Array[ shape1,shape2,shape3,shape4 ];
//               arr[i].blendMode = "invert";
            }
        }
    }
}







//          shape.graphics.lineStyle( 0, 0xFF0000, 0.5 );