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

Tween24 Test (フル活用版)

import aquioux.display.colorUtil.CycleRGB;
import aquioux.sketch.Dot;

Tween24 Test
Compare : http://wonderfl.net/c/s6cV (use Tweener)
@author Aquioux(Yoshida, Akio)
Get Adobe Flash player
by a_24 03 Oct 2012
  • Forked from Aquioux's Tween24 Test
  • Diff: 35
  • Related works: 2
  • Talk

    a_24 at 03 Oct 2012 06:14
    serial() の途中に loop() を挟むと正常に動作しないというバグを不運にも発見してしまいました。 直しますごめんなさいごめんなさい

    Tags

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

// forked from Aquioux's Tween24 Test
package {
    import a24.tween.Tween24;
    //import aquioux.display.colorUtil.CycleRGB;
    //import aquioux.sketch.Dot;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    [SWF(width = "465", height = "465", frameRate = "60", backgroundColor = "#FFFFFF")]
    /**
     * Tween24 Test
     * Compare : http://wonderfl.net/c/s6cV (use Tweener)
     * @author Aquioux(Yoshida, Akio)
     */
    public class MainTween24 extends Sprite {
        
        public function MainTween24() {
            var angle:Number = 0;
            for (var cntY:int = 0; cntY < 47; cntY++) {
                for (var cntX:int = 0; cntX < 47; cntX++) {
                    var dot:Dot = new Dot(5, CycleRGB.getColor(angle+=0.15));
                    
                        Tween24.serial(
                            Tween24.prop(dot).xy(cntX * 10 + 2.5, cntY * 10 + 2.5).scale(0),
                            Tween24.addChild(this, dot),
                            Tween24.loop(0,
                                Tween24.funcAndWaitEvent(dot, "complete", dotTween, dot)
                            )
                            //Tween24.tween(dot, 1).scale(0)
                        ).play();
                }
            }
        }
        
       private function dotTween(dot:Dot):void
       {
           Tween24.serial(
               Tween24.tween(dot, 1).scale(Math.random()),
               Tween24.eventDispatch(dot, new Event("complete"))
           ).play();
       }
    }
}



//package aquioux.sketch {
    import flash.display.Shape;
    /*public*/ class Dot extends Shape {
        public function Dot(radius:Number = 5, color:uint = 0x000000) {
            graphics.beginFill(color);
            graphics.drawCircle(0, 0, radius);
            graphics.endFill();
        }
    }
//}

//package aquioux.display.colorUtil {
    /**
     * コサインカーブで色相環的な RGB を計算
     * @author Aquioux(YOSHIDA, Akio)
     */
    /*public*/ class CycleRGB {
        /**
         * 32bit カラーのためのアルファ値(0~255)
         */
        static public function get alpha():uint { return _alpha; }
        static public function set alpha(value:uint):void {
            _alpha = (value > 0xFF) ? 0xFF : value;
        }
        private static var _alpha:uint = 0xFF;
    
        private static const PI:Number = Math.PI;        // 円周率
        private static const DEGREE120:Number  = PI * 2 / 3;    // 120度(弧度法形式)
        
        /**
         * 角度に応じた RGB を得る
         * @param    angle    HSV のように角度(度数法)を指定
         * @return    色(0xNNNNNN)
         */
        public static function getColor(angle:Number):uint {
            var radian:Number = angle * PI / 180;
            var r:uint = (Math.cos(radian)             + 1) * 0xFF >> 1;
            var g:uint = (Math.cos(radian + DEGREE120) + 1) * 0xFF >> 1;
            var b:uint = (Math.cos(radian - DEGREE120) + 1) * 0xFF >> 1;
            return r << 16 | g << 8 | b;
        }
       
        /**
         * 角度に応じた RGB を得る(32bit カラー)
         * @param    angle    HSV のように角度(度数法)を指定
         * @return    色(0xNNNNNNNN)
         */
        public static function getColor32(angle:Number):uint {
            return _alpha << 24 | getColor(angle);
        }
    }
//}