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

TextFieldから文字列がはみ出した時の処理

Get Adobe Flash player
by nium 26 Dec 2008
    Embed
package {
    import flash.display.Sprite;
    import flash.text.TextField;
    
    public class Main extends Sprite {
        public function Main() {
            var tf:TextField = addChild( new TextField() ) as TextField;
            tf.width = 100;
            tf.text = "あいうえおかきくけこさしすせそ";
            
            if ( tf.maxScrollH > 0 ) {
                tf.appendText( "..." );
                while ( tf.maxScrollH > 0 ) {
                    var words:Array = tf.text.split( "" );
                    words.splice( words.length - 4, 1);
                    tf.text = words.join( "" );
                }
            }
        }
    }
}