In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

createGradientBoxの意味(RADIAL)

RADIALの場合は、rotationを指定しても意味がなさそう。
Get Adobe Flash player
by nabe 29 Dec 2008
    Embed
/*
RADIALの場合は、rotationを指定しても意味がなさそう。
*/
// forked from nabe's createGradientBoxの意味(LINEAR)
// forked from nabe's ソースの雛形
package {

    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;

    [SWF(width="465", height="465", backgroundColor="0xAABBCC", frameRate="1")];  
    public class BaseClass extends Sprite {

        private const num_:uint = 64;
        private var current_:uint = 0;

        private var fill_:Shape;

        private const rect_:Rectangle = new Rectangle(10, 20, 200, 300);

        public function BaseClass () {
        //コンストラクタ。ここから全体の処理が開始する。
        //1.初期化処理の呼び出しを仕込むに留める。
            addEventListener(Event.ADDED_TO_STAGE, init_);
        }

        private function init_ (event_:Event):void {
        //初期化処理。
        //1.用済みのリスナ登録を解除する。
            event_.target.removeEventListener(event_.type, arguments.callee);

        //2.表示要素を組み立てる。
            buildShapes_();

        //3.アニメーション処理を登録する。
            addEventListener(Event.ENTER_FRAME, update_);
        }

        private function buildShapes_ ():void {
        //サンプル処理。

            fill_ = new Shape();
            addChild(fill_);

            var lines_:Shape = new Shape();
            addChild(lines_);

            var graphics_:Graphics = lines_.graphics;
            graphics_.lineStyle(0, 0);
            graphics_.drawRect(rect_.x, rect_.y, rect_.width, rect_.height);
            graphics_.drawEllipse(rect_.x, rect_.y, rect_.width, rect_.height);
        }

        private function update_ (event_:Event):void {
            current_ = (current_ + 1) % num_;
            var rotation_:Number = Math.PI * current_ * 2/ num_;
            var matrix_:Matrix = new Matrix();
            matrix_.createGradientBox(rect_.width, rect_.height, rotation_, rect_.x, rect_.y);
            var graphics_:Graphics = fill_.graphics;
            graphics_.clear();
            graphics_.beginGradientFill(
                GradientType.RADIAL,
                [0x7F7F7F, 0xFFFFFF],
                [0xFF, 0xFF],
                [0, 0xFF],
                matrix_,
                SpreadMethod.REPEAT
            );
            graphics_.drawRect(rect_.x, rect_.y, rect_.width, rect_.height);
            graphics_.endFill();
        }

    }

}