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

flash on 2011-5-18

...
@author michiro
Get Adobe Flash player
by sinketu 19 May 2011
    Embed
/**
 * Copyright sinketu ( http://wonderfl.net/user/sinketu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/m5Kq
 */

package 
{
    
    import caurina.transitions.Tweener;
    import caurina.transitions.properties.*;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    
    import flash.display.*;
    import flash.filters.*;
    import flash.geom.*;
    [SWF(width="465", height="465", backgroundColor="0", frameRate="30")]

    /**
     * ...
     * @author michiro
     */
    public class Main extends Sprite 
    {
        private var w:Number;
        private var h:Number;
        private var txtbox:MovieClip;
        private var map:BitmapData;
        private var pos:Point;
        private var blurx:Number;
        private var blury:Number;
        private var alp:Number;
        private var glow:GlowFilter;
        private var goal:Point;
        private var spArray:Array = [];
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e:Event = null):void 
        {
            FilterShortcuts.init();
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            createGradientColor();
            createText();
            addFilter();
            
        }
        
        private function createGradientColor():void
        {
            w = stage.stageWidth;
            h = stage.stageHeight;
            
            // --- 置き換えマップイメージ作成
            map = new BitmapData(w, h, true , 0);
            var myBitmap:Bitmap = new Bitmap(map);
            var mc:MovieClip = new MovieClip();
            
            var matrix:Matrix = new Matrix();
            //matrix.createGradientBox(40, 40, Math.PI, 0, 0);
            matrix.createGradientBox(40, 1, 0, 0, 0);
            mc.graphics.beginGradientFill("linear", [0xFF0000, 0x0000FF], [1, 1], [34, 220], matrix, "reflect");
            mc.graphics.drawRect(0, 0, w, h);
            mc.graphics.endFill();

            map.draw(mc);
        }
        
        private var myWords:Array = [    
            "よろしくおねがいします",
        ]
        private function createText():void
        {
            // --- テキスト作成
            txtbox = new MovieClip();
            addChild(txtbox);
            var txt:String="よろしくおねがいします";
            for (var i:uint = 0; i < txt.length; i ++ ) {
                var mySprite:Sprite = new Sprite();
                spArray.push(mySprite);
                mySprite.x = i * 40;
                txtbox.addChild(mySprite);
                mySprite.scaleY = 0.1;
                
                var copytxt:TextField = new TextField();
                
                mySprite.addChild(copytxt);
                var fmt:TextFormat = new TextFormat();
                fmt.font = "_明朝";
                fmt.size = 40;
                copytxt.defaultTextFormat = fmt;
                
                //
                //copytxt.embedFonts = true;
                copytxt.text = txt.slice( i, i + 1);
                copytxt.y = -20//copytxt.textHeight / 2;
                copytxt.selectable = false;
                copytxt.textColor = 0xFFFFFF;
                copytxt.autoSize = TextFieldAutoSize.LEFT;

                txtbox.x = (w-txtbox.width)/2;
                txtbox.y = (h-txtbox.height)/2;
                txtbox.blendMode = "add";
                
                Tweener.addTween(mySprite, { scaleY:1, time:0.5, delay:i*0.15 } );
            }
        }
        
        private function addFilter():void
        {
            // --- フィルタ 変数
            glow = new GlowFilter(0x0044CC, 20, 10, 10, 5, 3, false, false);
            blurx = 20; 
            blury = 10;
            alp = 5;

            pos = new Point(-txtbox.width, 0);
            goal = new Point(txtbox.width + 240, 0)
            
            addEventListener(Event.ENTER_FRAME, xEnterFrame);
            
            stage.addEventListener(MouseEvent.CLICK, xClick);
            
        }
        
        private function xClick(e:MouseEvent):void 
        {
            pos = new Point(-txtbox.width, 0);
            goal = new Point(txtbox.width + 240, 0);
            blurx = 30; 
            blury = 10;
            alp = 5;
            pos.x = -txtbox.width;
            
        }
        
        private function xEnterFrame(e:Event):void 
        {
                var dmf:DisplacementMapFilter = new DisplacementMapFilter(map, pos, 1, 1, 7,4, "clamp");
                var blur:BlurFilter = new BlurFilter(blurx, blury, 3);
                var matrix:Array = [
                    1, 1, .5, 0, 1, 
                    1, 1, .5, 0, 1, 
                    2, .5, 1, 0, 1, 
                    0, 0, 0, alp, 0
                    ];
                var clrmrx:ColorMatrixFilter = new ColorMatrixFilter(matrix);
                txtbox.filters = [dmf, glow, blur, clrmrx];

                pos.x += (goal.x-pos.x)*0.02;
                blurx += -blurx*0.03;
                blury += -blury * 0.03;
                alp += (1-alp)*0.07;
        }
        
    }
}