Copy link to clipboard
Copied
hallo, ich versuche einem dynamisches Textfeld einen Text zu schreiben.
es klappt nicht.
beispiel:
instanzname vom textfeld ist textfeld.
var land_1 = "Hamburg";
textfeld = land_1;
dank vorab!
Copy link to clipboard
Copied
Hi.
You need to modify the value of the .text property of a dynamic text field instance to change the text.
And be aware that in both AS3 and JavaScript variables and properties names can't contain spaces and it's recommended to use camelCase for naming variables and not snake_case.
With that being said, you can change the text of a text field instance like this:
JS
var land1 = "Hamburg";
this.textBox.text = land1;
AS3
var land1:String = "Hamburg"; // setting the type is not mandatory but it's really advisable
textBox.text = land1; // you can use the "this" keyword in AS3 but for regular main timeline references is often not necessary
Regards,
JC
Copy link to clipboard
Copied
Danke, es funktioniert !
Noch eine Frage:
wenn ich 2 textfelder im gleichen Frame habe, zB.
dann funktioniert es nicht ???????
var land1 = "Hamburg";
var land2 = "Berlin";
this.textBox1 = land1;
this.textBox2 = land2;
Copy link to clipboard
Copied
You're welcome!
About the question, you're forgetting the .text property.
var land1 = "Hamburg";
var land2 = "Berlin";
this.textBox1.text = land1;
this.textBox2.text = land2;
Copy link to clipboard
Copied
Danke!! Es klappt.