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

forked from: Tweensyのイージング

easeClasses宣言したくない…
/**
 * Copyright yasai ( http://wonderfl.net/user/yasai )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fClT
 */

// forked from nacookan's Tweensyのイージング
/**
 * easeClasses宣言したくない…
 */
package {
    import flash.display.*;
    import flash.events.*;
    import com.flashdynamix.motion.*;
    import fl.motion.easing.*;
	import flash.utils.*;
	
    public class FlashTest extends Sprite {
        public function FlashTest() {
			var _x:Number = 10;
			var _y:Number = 0;
			var size:int = 70;
			//宣言したくないけど、宣言する。
			var easeClasses:Vector.<Class> = Vector.<Class>([
				Back,
				Bounce,
				Elastic,
				Linear,
				Cubic,
				Quadratic,
				Circular,
				Exponential,
				Sine,
				Quintic,
				Quartic
			]);
			var easeTypes:Vector.<String> = Vector.<String>([
				"Back",
				"Bounce",
				"Elastic",
				"Linear",
				"Cubic",
				"Quadratic",
				"Circular",
				"Exponential",
				"Sine",
				"Quintic",
				"Quartic"
			]);
			for each(var easeType:String in easeTypes) {
				var easeClass:Class =  getDefinitionByName("fl.motion.easing." + easeType) as Class;
				if (easeClass == null) continue;
				var typeXML:XML = describeType(easeClass);
				for each(var method:XML in typeXML..method) {
					addSprite(generateGraph(easeClass[method.@name.toString()]), _x, _y);
					_x += size;
					if (_x + size >= 465) {
						_x = 10;
						_y += size;
					}
				}
			}
        }
        
        private function generateGraph(ease:Function):Sprite{
            var time:Number = 2;
            var wide:Number = 1;
            var width:Number = 70;
            var size:Number = 70;
            var insize:Number = size * 0.8;
            var outsize:Number = size * 0.1;
            var graph:Sprite = new Sprite();
            graph.graphics.lineStyle(1, 0x5050e0);
            graph.graphics.moveTo(0, insize);
            var dummy:Sprite = new Sprite();
            var tl:TweensyTimeline = Tweensy.fromTo(dummy, {y:0}, {y:insize}, time, ease);
            var frame:Number = 0;
            dummy.addEventListener(Event.ENTER_FRAME, function(e:Event):void{
                if(tl.finished){
                    dummy.removeEventListener(e.type, arguments.callee);
                    return;
                }
                graph.graphics.lineTo(frame++ * wide, insize - dummy.y);
            });
            var grapharea:Sprite = new Sprite();
            grapharea.addChild(graph);
            grapharea.graphics.lineStyle(1, 0xa0a0a0);
            grapharea.graphics.moveTo(0, outsize);
            grapharea.graphics.lineTo(width, outsize);
            grapharea.graphics.moveTo(0, size - outsize);
            grapharea.graphics.lineTo(width, size - outsize);
            graph.y = outsize;
            return grapharea;
        }
        
        private function addSprite(sprite:Sprite, x:Number, y:Number):void{
            addChild(sprite);
            sprite.x = x;
            sprite.y = y;
        }
    }
}