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

UnicodeRange

フォントの必要な文字のみをEmbedするためのツール。
Get Adobe Flash player
by bkzen 28 Mar 2012
/**
 * Copyright bkzen ( http://wonderfl.net/user/bkzen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fuJF
 */

package  
{
    import com.bit101.components.PushButton;
    import com.bit101.components.Style;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    
    /**
     * フォントの必要な文字のみをEmbedするためのツール。
     * @author jc at bk-zen.com
     */
    [SWF (backgroundColor = "0xFFFFFF", frameRate = "30", width = "465", height = "465")]
    public class Test85 extends Sprite 
    {
        private var resultTxt:TextField;
        private var inputTxt:TextField;
        private var btn:PushButton;
        
        public function Test85() 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e: Event = null): void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            //
            Style.fontName = "_ゴシック";
            Style.embedFonts = false;
            Style.fontSize = 12;
            btn = new PushButton(this, 0, 0, "変換", onClickBtn);
            btn.draw();
            
            resultTxt = new TextField();
            inputTxt = new TextField();
            inputTxt.multiline = resultTxt.multiline = inputTxt.wordWrap = resultTxt.wordWrap = true;
            inputTxt.type = TextFieldType.INPUT;
            
            inputTxt.width = resultTxt.width = stage.stageWidth - 10;
            resultTxt.height = inputTxt.height = stage.stageHeight - btn.height - 20 >> 1;
            resultTxt.border = inputTxt.border = true;
            inputTxt.x = inputTxt.y = 5;
            btn.x = stage.stageWidth - btn.width >> 1;
            btn.y = inputTxt.y + inputTxt.height + 5;
            resultTxt.x = 5;
            resultTxt.y = btn.y + btn.height + 5;
            addChild(inputTxt);
            addChild(resultTxt);
            
        }
        
        private function onClickBtn(e: MouseEvent):void 
        {
            var str: String = inputTxt.text;
            var i: uint, n: uint = str.length;
            var obj: Object = { };
            for (i = 0; i < n; i++) 
            {
                var r: Number = str.charCodeAt(i);
                obj[r] = "";
            }
            var arr: Array = [];
            i = 0;
            for (var name:String in obj) 
            {
                var t: String = Number(name).toString(16);
                var j: uint = t.length;
                for (; j < 4; j++) 
                {
                    t = "0" + t;
                }
                arr[i++] = "U+" + t;
            }
            arr.sort();
            resultTxt.text = "unicodeRange = '" + arr.join(", ") + "'";
        }
        
    }

}