反射エフェクトを入れて中心回転

by yooyke
CoverFlowを作ろうと思ったのでテスト
入れ子にしてベースを回転させるのは簡単だが、オブジェクト数は少ない方が良いので実験
♥0 | Line 48 | Modified 2011-01-02 13:17:46 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.geom.Matrix;
    import flash.display.GradientType;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            
            const w:Number = 64;
            const h:Number = 96;
            var mat:Matrix = new Matrix();
            mat.createGradientBox(w, h, Math.PI * 0.5, 0, 0);

            var source:Sprite = new Sprite();
            source.graphics.beginGradientFill(
                GradientType.LINEAR, 
                [0xafafff, 0x000000],
                [1, 1],
                [0x00, 0xFF],
                mat
                );
            source.graphics.drawRect(0, 0, w, h);
            source.graphics.endFill();
//            addChild(source);

            var mask:Sprite = new Sprite();
            mask.graphics.beginGradientFill(
                GradientType.LINEAR, 
                [0x000000, 0x000000],
                [1, 0],
                [0x00, 0xFF],
                mat
                );
            mask.graphics.drawRect(0, 0, w, h);
            mask.graphics.endFill();
            mask.y = h;
            addChild(mask);
            
            var rad:Number = Math.PI;
            mat.identity();
            mat.rotate(rad);
            mat.translate(w, h);
            
            var bd:BitmapData = new BitmapData(source.width, source.height, true, 0x00ffffff);
            bd.draw(source, mat);
            

            var bmp:Bitmap = new Bitmap(bd);
            bmp.mask = mask;
            bmp.x = 0;
            bmp.y = h;
            addChild(bmp);
        }
    }
}