flash on 2011-11-6
♥0 |
Line 32 |
Modified 2011-11-06 09:57:07 |
MIT License
archived:2017-03-20 06:20:24
ActionScript3 source code
/**
* Copyright tjoen ( http://wonderfl.net/user/tjoen )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sOcg
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.events.MouseEvent;
public class TextField_setTextFormatExample extends Sprite {
private var myTextField:TextField = new TextField();
private var newFormat:TextFormat = new TextFormat();
public function TextField_setTextFormatExample() {
myTextField.autoSize = TextFieldAutoSize.LEFT;
myTextField.selectable = false;
myTextField.background = true;
myTextField.text = "No matter where you click on this text field only the TEXT IN ALL CAPS changes format.";
myTextField.addEventListener(MouseEvent.CLICK, clickHandler);
newFormat.color = 0xFF0000;
newFormat.size = 18;
newFormat.underline = true;
newFormat.italic = true;
this.addChild(myTextField);
}
private function clickHandler(event:MouseEvent):void {
var currentTextFormat:TextFormat = myTextField.getTextFormat(55);
if(currentTextFormat.size != 18) {
myTextField.setTextFormat(newFormat, 54, 70);
}
else {
myTextField.setTextFormat(myTextField.defaultTextFormat);
}
}
}
}