-
change alignment dyn.textfield from a button
Hi there,
Anyone know how I can make a dynamic tekstfield change it's alignment from left to right when hitting a button?Possible?How?
Big thx in advance
Grtz,
-
Senior Member
Hi,
you could use the text format object,
code:
// create the text format object
var fmt = new TextFormat();
fmt.align = "left";
// and place the text hello world in a textfield (instance name txt)
txt.text = "hello world";
txt.setTextFormat(fmt);
// create an onPress event for the button (instance name btn)
btn.onPress = function() {
// if the alignment was left set it to right, otherwise set it to left
fmt.align = fmt.align == "left" ? "right" : "left";
// apply the formating to the text field
txt.setTextFormat(fmt);
};
-
Hi catbert303,
My tekst is loaded from an xml file.So this line is not needed?
txt.text = "hello world";
This is the action I use to send my tekst through my dyn.textfield
Actions.subtitel = function(msg) {
trace(msg);
subtitel_txt.html = true;
subtitel_txt.htmlText = msg;
};
So subtitel_txt is the instancename of my dyn.textfield. how can I make a button change the alignment of the Dyn.textfield(subtitel_txt) from "left" to "right"?Help:s.
Grtz,
-
Senior Member
code:
btn.onPress = function() {
fmt = new TextFormat();
fmt.align = "right";
subtitel_txt.setTextFormat(fmt);
};
would make the text contained in the field subtitel_txt right aligned when the button (instance name btn) was pressed
-
thx works like a charm. Your a star
Grtz,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|