※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


FORKED

Weirdness of the height property of TextField forked from: Weirdness of the height property of TextField [diff(2)]

  1. // forked from 9re's Weirdness of the height property of TextField
  2. package  
  3. {
  4.     import flash.display.Sprite;
  5.     import flash.display.StageScaleMode;
  6.     import flash.text.TextField;
  7.     import flash.text.TextFieldAutoSize;
  8.     import flash.text.TextFormat;
  9.     import flash.text.TextFormatAlign;
  10.     // http://level0.kayac.com/2009/08/post_39.php
  11.     public class TextFieldAutoSizeExample_0 extends Sprite
  12.     {
  13.         private const MAX_SIZE:int = 32;
  14.         private const MIN_SIZE:int = 8;
  15.         
  16.         public function TextFieldAutoSizeExample_0() 
  17.         {
  18.             var tf:TextField = new TextField();
  19.             var tfm:TextFormat = new TextFormat("_sans"120nullnullnullnullnull, TextFormatAlign.JUSTIFY);
  20.             var i:int = MAX_SIZE;
  21.             var str:String = "Flash Player Bug??\n\nFlash Player sometimes fails to get proper height of TextField. This may issue from internal text rendering process. You can avoid this problem by executing getter method - the height property is internally implemented as getter and setter method - before using the height property. If you comment out the line 39, the code fails to work properly.这是中文测试,前述の通り、ビルトインクラスのプロパティの多くはアクセサであるため、少し予想外の挙動となってしまうことがあります。前述の通り、ビルトインクラスのプロパティの多くはアクセサであるため、少し予想外の挙動となってしまうことがあります。前述の通り、ビルトインクラスのプロパティの多くはアクセサであるため、少し予想外の挙動となってしまうことがあります。";
  22.             
  23.             stage.scaleMode = StageScaleMode.NO_SCALE;
  24.             
  25.             tf.autoSize = TextFieldAutoSize.LEFT;
  26.             tf.wordWrap = true;
  27.             tf.multiline = true;
  28.             tf.text = str;
  29.             tf.width = 300;
  30.             tf.height = 1;
  31.             addChild(tf);
  32.             
  33.             var tfHeight:int;
  34.             
  35.             while (i >= MIN_SIZE) {
  36.                 tfm.size = i--;
  37.                 tf.setTextFormat(tfm);
  38.                 
  39.                 // the follwing line avoids the problem
  40.                 tf.height;
  41.                 tfHeight = tf.height;
  42.                 
  43.                 if (tfHeight < 300)
  44.                     break;
  45.             }
  46.             
  47.             
  48.             tf = new TextField();
  49.             tf.width  = 200;
  50.             tf.text = "fontSize: " + i.toString() + " tf.height: " + tfHeight.toString();
  51.             tf.x = 310;
  52.             addChild(tf);
  53.         }
  54.         
  55.     }
  56.     
  57. }
noswf
  1. // forked from 9re's Weirdness of the height property of TextField
  2. package  
  3. {
  4.     import flash.display.Sprite;
  5.     import flash.display.StageScaleMode;
  6.     import flash.text.TextField;
  7.     import flash.text.TextFieldAutoSize;
  8.     import flash.text.TextFormat;
  9.     import flash.text.TextFormatAlign;
  10.     // http://level0.kayac.com/2009/08/post_39.php
  11.     public class TextFieldAutoSizeExample_0 extends Sprite
  12.     {
  13.         private const MAX_SIZE:int = 32;
  14.         private const MIN_SIZE:int = 8;
  15.         
  16.         public function TextFieldAutoSizeExample_0() 
  17.         {
  18.             var tf:TextField = new TextField();
  19.             var tfm:TextFormat = new TextFormat("_sans"120nullnullnullnullnull, TextFormatAlign.JUSTIFY);
  20.             var i:int = MAX_SIZE;
  21.             var str:String = "Flash Player Bug??\n\nFlash Player sometimes fails to get proper height of TextField. This may issue from internal text rendering process. You can avoid this problem by executing getter method - the height property is internally implemented as getter and setter method - before using the height property. If you comment out the line 39, the code fails to work properly.";
  22.             
  23.             stage.scaleMode = StageScaleMode.NO_SCALE;
  24.             
  25.             tf.autoSize = TextFieldAutoSize.LEFT;
  26.             tf.wordWrap = true;
  27.             tf.multiline = true;
  28.             tf.text = str;
  29.             tf.width = 300;
  30.             tf.height = 1;
  31.             addChild(tf);
  32.             
  33.             var tfHeight:int;
  34.             
  35.             while (i >= MIN_SIZE) {
  36.                 tfm.size = i--;
  37.                 tf.setTextFormat(tfm);
  38.                 
  39.                 // the follwing line avoids the problem
  40.                 tf.height;
  41.                 tfHeight = tf.height;
  42.                 
  43.                 if (tfHeight < 300)
  44.                     break;
  45.             }
  46.             
  47.             
  48.             tf = new TextField();
  49.             tf.width  = 200;
  50.             tf.text = "fontSize: " + i.toString() + " tf.height: " + tfHeight.toString();
  51.             tf.x = 310;
  52.             addChild(tf);
  53.         }
  54.         
  55.     }
  56.     
  57. }
noswf
  1. // forked from 9re's Weirdness of the height property of TextField
  2. package  
  3. {
  4.     import flash.display.Sprite;
  5.     import flash.display.StageScaleMode;
  6.     import flash.text.TextField;
  7.     import flash.text.TextFieldAutoSize;
  8.     import flash.text.TextFormat;
  9.     import flash.text.TextFormatAlign;
  10.     // http://level0.kayac.com/2009/08/post_39.php
  11.     public class TextFieldAutoSizeExample_0 extends Sprite
  12.     {
  13.         private const MAX_SIZE:int = 32;
  14.         private const MIN_SIZE:int = 8;
  15.         
  16.         public function TextFieldAutoSizeExample_0() 
  17.         {
  18.             var tf:TextField = new TextField();
  19.             var tfm:TextFormat = new TextFormat("_sans"120nullnullnullnullnull, TextFormatAlign.JUSTIFY);
  20.             var i:int = MAX_SIZE;
  21.             var str:String = "Flash Player Bug??\n\nFlash Player sometimes fails to get proper height of TextField. This may issue from internal text rendering process. You can avoid this problem by executing getter method - the height property is internally implemented as getter and setter method - before using the height property. If you comment out the line 39, the code fails to work properly.";
  22.             
  23.             stage.scaleMode = StageScaleMode.NO_SCALE;
  24.             
  25.             tf.autoSize = TextFieldAutoSize.LEFT;
  26.             tf.wordWrap = true;
  27.             tf.multiline = true;
  28.             tf.text = str;
  29.             tf.width = 300;
  30.             tf.height = 1;
  31.             addChild(tf);
  32.             
  33.             var tfHeight:int;
  34.             
  35.             while (i >= MIN_SIZE) {
  36.                 tfm.size = i--;
  37.                 tf.setTextFormat(tfm);
  38.                 
  39.                 // the follwing line avoids the problem
  40.                 tf.height;
  41.                 tfHeight = tf.height;
  42.                 
  43.                 if (tfHeight < 300)
  44.                     break;
  45.             }
  46.             
  47.             
  48.             tf = new TextField();
  49.             tf.width  = 200;
  50.             tf.text = "fontSize: " + i.toString() + " tf.height: " + tfHeight.toString();
  51.             tf.x = 310;
  52.             addChild(tf);
  53.         }
  54.         
  55.     }
  56.     
  57. }
noswf
Get Adobe Flash Player