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: 【解決法求む】TFの先頭行が切れる

Get Adobe Flash player
by saharan 09 Jun 2011

    Talk

    romatica at 09 Jun 2011 05:51
    こんなやりかたが!!
    romatica at 09 Jun 2011 05:54
    あ、 でもInput Type だとだめか。。
    saharan at 09 Jun 2011 11:19
    Input Type だとだめでしたか… 色々試してみます。。
    saharan at 09 Jun 2011 11:39
    Event.CHANGEを使ってInputにも対応させてみました。
    Embed
/**
 * Copyright saharan ( http://wonderfl.net/user/saharan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4hPs
 */

// forked from romatica's 【解決法求む】TFの先頭行が切れる
package {
    import flash.text.*;
    import flash.events.*;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        private var tf1:TextField;
        private var tf2:TextField;
        private var tf3:TextField;
        public function FlashTest() {
            // write as3 code here..
            var str : String = "【解決法求む】TextFormatでleading指定した、テキストフィールド。";
            str += "\n" + "テキスト選択し、行末を超えてドラッグすると、";
            str += "\n" + "先頭行が切れる (Mac 10.6 「FP10.3.181.22」&「11.0.0.60 β」で確認)";


            var tfm:TextFormat = new TextFormat();
            tfm.leading = 10;

            // ----------------------------------------------------------------------
            // Leadingあり

            tf1 = addChild(new TextField()) as TextField;
            tf1.defaultTextFormat = tfm;//leading適用
            tf1.multiline = true;
            tf1.text = "Leading あり Ver: " + str;
            tf1.autoSize = TextFieldAutoSize.LEFT;
            tf1.height += tfm.leading;
            tf1.autoSize = TextFieldAutoSize.NONE;

            // ----------------------------------------------------------------------
            // Input Type

            tf2 = addChild(new TextField()) as TextField;
            tf2.defaultTextFormat = tfm; // leading適用
            tf2.multiline = true;
            tf2.text = "Input Type Ver: " + str;
            tf2.autoSize = TextFieldAutoSize.LEFT;
            tf2.height += tfm.leading;
            tf2.type = TextFieldType.INPUT;
            tf2.autoSize = TextFieldAutoSize.NONE;
            tf2.y = 150;
            tf2.addEventListener(Event.CHANGE, function(event:Event):void {
                tf2.autoSize = TextFieldAutoSize.LEFT;
                tf2.height += tf2.defaultTextFormat.leading;
                tf2.autoSize = TextFieldAutoSize.NONE;
            });

            // ----------------------------------------------------------------------            
            // Leadingなし

            tf3 = addChild(new TextField()) as TextField;
            tf3.multiline = true;
            tf3.text = "Leading なし Ver: " + str;
            tf3.autoSize = TextFieldAutoSize.LEFT;
            tf3.y = 300;
        }
    }
}