Dynamisches Textfeld

Explorer ,
May 15, 2020 May 15, 2020

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!

TOPICS
Code

Views

749

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 15, 2020 May 15, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 17, 2020 May 17, 2020

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;

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 17, 2020 May 17, 2020

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;

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 17, 2020 May 17, 2020

Copy link to clipboard

Copied

LATEST

Danke!! Es klappt. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines