Reputation: 63
To start off, I am quite new at Actionscipt, so please bear with me. I am trying to make a text field that changes as the variable date goes up. This is my coding (it is on a layer):
var day:int = 1;
var date:TextField = new TextField();
if (day = 1) date.txt = "August 1";
if (day = 2) date.txt = "August 2";
date.x = 548.1
date.y = 58.5
var format: TextFormat = new TextFormat
format.color = 0xFFFFFF;
format.font = "Constantia";
format.bold = false
txt.setTextFormat( format);
stage.addChild(date)
I am getting errors for this however, and I am confused as to why. The error is this:
1151: A conflict exists with definition date in namespace internal. Source: var date:TextField = new TextField();
Again, I am new at all of this, and I would appreciate any help at all. Thank-you.
(Edit)
I've fixed these problems, and given my textfield the instance name dateTextField. The coding is now:
var day:int = 1;
var dateTextField:TextField = new TextField();
if (day == 1) dateTextField.text = "August 1";
if (day == 2) dateTextField.text = "August 2";
dateTextField.x = 548;
dateTextField.y = 58;
var format: TextFormat = new TextFormat ();
format.color = 0xFFFFFF;
format.font = "Constantia";
format.bold = false;
txt.setTextFormat( format);
stage.addChild(dateTextField);
Yet I still get the same error?
1151: A conflict exists with definition dateTextField in namespace internal.
Source: var dateTextField:TextField = new TextField();
Upvotes: 1
Views: 1378
Reputation: 63
Wow, I just realized how complicated I was making this all. I simply named the text field date, set my font and size there, and made my coding:
var day:int = 1;
if (day==1) date.text = "July 1";
But thank-you for your help, it helped me see the coding in a new light.
Upvotes: 0
Reputation: 8503
lines 3 and four should be:
if (day == 1) dateTextField.text = "August 1";
if (day == 2) dateTextField.text = "August 2";
Upvotes: 0
Reputation: 7550
You are missing some colons and an ='s sign. change this var format: TextFormat = new TextFormat format.color - 0xFFFFFF; to
var format: TextFormat = new TextFormat();
format.color = 0xFFFFFF;
and also check that at the end of each line you are have a ";" I can see one other line that is missing the ;
Upvotes: 0
Reputation: 90853
Most likely, you have already defined date
somewhere else. Rename the variable to something more specific, for example dateTextField
.
Upvotes: 2