|
| 1 | +package { |
| 2 | +import flash.display.*; |
| 3 | +import flash.text.*; |
| 4 | +import flash.events.*; |
| 5 | +import flash.geom.*; |
| 6 | + |
| 7 | +public class Test extends MovieClip { |
| 8 | + public function Test() { |
| 9 | + var tf = new TextField(); |
| 10 | + tf.multiline = true; |
| 11 | + tf.defaultTextFormat = new TextFormat("Unknown Font"); |
| 12 | + tf.htmlText = "<p align=\"center\">x</p>"; |
| 13 | + |
| 14 | + trace("Before newline removal:"); |
| 15 | + trace(" " + tf.text.length); |
| 16 | + |
| 17 | + tf.replaceText(1, 2, ""); |
| 18 | + |
| 19 | + trace("After newline removal:"); |
| 20 | + trace(" " + tf.text.length); |
| 21 | + trace(" " + tf.htmlText); |
| 22 | + |
| 23 | + tf.htmlText = "<P ALIGN=\"CENTER\"><FONT FACE=\"Unknown Font\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">x</FONT></P>"; |
| 24 | + |
| 25 | + trace("After setting to the same value:"); |
| 26 | + trace(" " + tf.text.length); |
| 27 | + trace(" " + tf.htmlText); |
| 28 | + |
| 29 | + tf.htmlText = "<P ALIGN=\"CENTER\"><FONT FACE=\"Unknown Font\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">x</FONT></P>"; |
| 30 | + |
| 31 | + trace("After setting to a slightly different value:"); |
| 32 | + trace(" " + tf.text.length); |
| 33 | + trace(" " + tf.htmlText); |
| 34 | + |
| 35 | + tf.htmlText = "<font face='Unknown Font 2'><b>x</b></font>"; |
| 36 | + |
| 37 | + trace("After setting to HTML x:"); |
| 38 | + trace(" " + tf.text.length); |
| 39 | + trace(" " + tf.htmlText); |
| 40 | + |
| 41 | + tf.text = "x"; |
| 42 | + |
| 43 | + trace("After setting text to x:"); |
| 44 | + trace(" " + tf.text.length); |
| 45 | + trace(" " + tf.htmlText); |
| 46 | + } |
| 47 | +} |
| 48 | +} |
0 commit comments