-
[RESOLVED] 1067: Implicit coercion of a value of type Number to an unrelated type String.
I searched the forum for an answer to this error, but couldn't find one. I am new to AS3 and am doing exercises in a textbook for CS3. I am doing the exercise exactly as it describes in the book, but I keep getting the error, "1067: Implicit coercion of a value of type Number to an unrelated type String."
My code looks like this (and yes, the instance name for the dynamic text box matches what I have written in the code):
Actionscript Code:
var myDate:Date = new Date(); myTextField_txt.text = myDate.getDate();
Seems very simple, right? All I want it to do is display the current date in this dynamic text field. This is exactly how the book tells me to write the code. I think the book may be wrong. I tried the same exercise using AS2 and it worked fine.
I e-mailed my instructor about this on Wednesday (it is for an advanced Flash course through eclasses.org) and haven't heard back yet, so it is a bit frustrating.
Thanks.
Last edited by jillesreina; 01-23-2011 at 12:06 PM.
-
myTextField_txt.text = String(myDate.getDate());
-
-
Same question,
im trying to add a score to my mix
here's my equation
var score:Number = 0;
if(bball1_mc.y >= 447.2){
bball1_mc.y = -71.8;
bball1_mc.x = randy;
score = score+10;
run = true;
}
score_txt.text = String(score());
it doesnt seem to work, some help would be nice
-
Originally Posted by bossross
im trying to add a score to my mix
here's my equation
var score:Number = 0;
if(bball1_mc.y >= 447.2){
bball1_mc.y = -71.8;
bball1_mc.x = randy;
score = score+10;
run = true;
}
score_txt.text = String(score());
it doesnt seem to work, some help would be nice
Try this for your last line instead:
score_txt.text = String(score)
The reason for this is that the solution to the OP's problem: myTextField_txt.text = String(myDate.getDate()); - the brackets in bold are because the .getDate part of the line is referring to a function, which is typically followed by () afterwards. For your own score, it is simply a variable and not a function which does not need the additional brackets.
I understand this is probably a little late for you given the age of the post, but perhaps this may be of help to someone else who finds this post in the future
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
|