Skip to main content
Inspiring
May 15, 2020
Question

Dynamisches Textfeld

  • May 15, 2020
  • 1 reply
  • 1010 views

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!

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
May 15, 2020

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

hds26846Author
Inspiring
May 17, 2020

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;

 

JoãoCésar17023019
Community Expert
Community Expert
May 17, 2020

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;