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

テキストでマスク (2)

////////////////////////////////////////////////////////////////////////////////
// テキストでマスク (2)
//
// グラデーション・マスク
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=462
////////////////////////////////////////////////////////////////////////////////
Get Adobe Flash player
by ProjectNya 12 Oct 2010
    Embed
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6kFE
 */

// forked from ProjectNya's テキストでマスク (1)
////////////////////////////////////////////////////////////////////////////////
// テキストでマスク (2)
//
// グラデーション・マスク
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=462
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.filters.BlurFilter;
    import flash.geom.Matrix;
    import flash.display.GradientType;

    [SWF(backgroundColor="#000000", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private var shape:Shape;

        public function Main() {
            //Wonderfl.capture_delay(1);
            init();
        }

        private function init():void {
            graphics.beginFill(0x000000);
            graphics.drawRect(0, 0, 465, 465);
            graphics.endFill();
            //
            var label:Label = new Label(465, 465, Label.CENTER);
            addChild(label);
            label.textColor = 0xFFFFFF;
            var str:String = "";
            for (var n:uint = 0; n < 65; n++) {
                str += "wonderfl ActionScript3.0 ";
            }
            label.text = str;
            //
            shape = new Shape();
            addChild(shape);
            var matrix:Matrix = new Matrix();
            matrix.createGradientBox(465, 465, 0.5*Math.PI, 0, 0);
            shape.graphics.beginGradientFill(GradientType.LINEAR, [0xFF0000, 0x330000], [1, 1], [0, 255], matrix);
            shape.graphics.drawRect(0, 0, 465, 465);
            shape.graphics.endFill();
            //
            shape.cacheAsBitmap = true;
            label.cacheAsBitmap = true;
            shape.mask = label;
        }
        
    }

}


//////////////////////////////////////////////////
// Labelクラス
//////////////////////////////////////////////////

import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFieldAutoSize;
import flash.text.AntiAliasType;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;

class Label extends Sprite {
    private var txt:TextField;
    private static var fontType:String = "_ゴシック";
    private var _width:uint = 20;
    private var _height:uint = 20;
    public static const LEFT:String = TextFormatAlign.LEFT;
    public static const CENTER:String = TextFormatAlign.CENTER;
    public static const RIGHT:String = TextFormatAlign.RIGHT;

    public function Label(w:uint, h:uint, align:String = LEFT) {
        _width = w;
        _height = h;
        draw(align);
    }

    private function draw(align:String):void {
        txt = new TextField();
        addChild(txt);
        txt.width = _width;
        txt.height = _height;
        txt.autoSize = align;
        txt.type = TextFieldType.DYNAMIC;
        txt.selectable = false;
        //txt.embedFonts = true;
        //txt.antiAliasType = AntiAliasType.ADVANCED;
        txt.antiAliasType = AntiAliasType.NORMAL;
        txt.multiline = true;
        txt.wordWrap = true;
        var tf:TextFormat = new TextFormat();
        tf.font = fontType;
        tf.size = 14;
        tf.align = align;
        txt.defaultTextFormat = tf;
        textColor = 0x000000;
        //txt.cacheAsBitmap = true;
    }
    public function set text(param:String):void {
        txt.text = param;
    }
    public function set textColor(param:uint):void {
        txt.textColor = param;
    }

}