Chapter 17 Example 3
♥0 |
Line 34 |
Modified 2009-06-28 05:11:22 |
MIT License
archived:2017-03-10 21:42:06
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5YUz
*/
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class ch17ex3 extends Sprite {
protected const TEXT:String = "Ernest Rutherford, (1871– 1937) was a New Zealand-born chemist and physicist who fathered nuclear physics.";
public function ch17ex3() {
var singlelinetf:TextField = newTF();
singlelinetf.multiline = false;
var multilinetf:TextField = newTF();
multilinetf.multiline = true;
multilinetf.wordWrap = false;
var wraptf:TextField = newTF();
wraptf.multiline = true;
wraptf.wordWrap = true;
}
protected function newTF():TextField {
var tf:TextField = new TextField();
tf.border = true;
tf.width = 300;
tf.height = 40;
tf.text = TEXT;
tf.y = 60 * numChildren;
tf.addEventListener(MouseEvent.CLICK, onClick);
addChild(tf);
return tf;
}
protected function onClick(event:MouseEvent):void {
var tf:TextField = TextField(event.target);
tf.autoSize = TextFieldAutoSize.LEFT;
}
}
}