cube

by awef
♥0 | Line 53 | Modified 2009-03-17 13:50:54 | MIT License
play

ActionScript3 source code

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

package
{
    import flash.display.Sprite;
    import caurina.transitions.Tweener;
    
    [SWF(backgroundColor="#000000")]
    
    public class main extends Sprite
    {
        private var obj:Sprite;
        function main()
        {
            obj = new Sprite();
            
            obj.x = stage.stageWidth / 2;
            obj.y = stage.stageHeight / 2;
            
            var s:uint = 80;
            
            var tmp:Sprite;
            
            tmp = new Sprite();
            tmp.z = s / 2;
            tmp.graphics.lineStyle(2, 0xFFFFFF);
            tmp.graphics.drawRect(-s / 2, -s / 2, s, s);
            obj.addChild(tmp);
            
            tmp = new Sprite();
            tmp.z = -s / 2;
            tmp.graphics.lineStyle(2, 0xFFFFFF);
            tmp.graphics.drawRect(-s / 2, -s / 2, s, s);
            obj.addChild(tmp);
            
            tmp = new Sprite();
            tmp.x = s / 2;
            tmp.graphics.lineStyle(2, 0xFFFFFF);
            tmp.graphics.drawRect(-s / 2, -s / 2, s, s);
            tmp.rotationY = 90;
            obj.addChild(tmp);
            
            tmp = new Sprite();
            tmp.x = -s / 2;
            tmp.graphics.lineStyle(2, 0xFFFFFF);
            tmp.graphics.drawRect(-s / 2, -s / 2, s, s);
            tmp.rotationY = 90;
            obj.addChild(tmp);
            
            stage.addChild(obj);
            
            testa();
            testb();
        }
        
        private function testa():void
        {
            obj.rotationY = 0;
            Tweener.addTween(obj, {rotationY:-360, time:4, transition:"linear", onComplete:testa});
        }
        
        private function testb():void
        {
            obj.rotationX = 0;
            Tweener.addTween(obj, {rotationX:360, time:6, transition:"linear", onComplete:testb});
        }
    }
}