Answered
Variable Data Type Error.
I have a fast question. I am setting up a variable with a
data type of Number, when I declare the variable it has a default
value.
I am trying to pass data to the variable from a input text box but I am getting an error when I run the Movie. I have tried both a input text box and a Dynamic Text box, but they both produce the same error.
If I remove the data typing from the variable declaration the Movie runs and it updates the variable data but from all that I have read this is not a good practice.
I have attached the code, could someone Please help me out. I do not remember having these types of problems with ActionScript 2.
Thanks for the help.
Code:
var rectangle:Shape;
var thick :Number = 2; // line thickness
var color:Number= 0x000000; // Holds the color value
myButton_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
{
color = colorField_txt.text; (Line 11)
thick = lineThick_txt.text; (Line 12)
rectangle = new Shape();
rectangle.graphics.lineStyle(thick, color, .5);
rectangle.graphics.drawRect(10, 10, 100, 150);
addChild(rectangle);
}
myButton_btn.buttonMode = true;
ERROR MESSAGE:
1067: Implicit coercion of a value of type String to an unrelated type Number. (Refers to line 11)
1067: Implicit coercion of a value of type String to an unrelated type Number. (Refers to line 12)
Thanks again for any help.
Mike
I am trying to pass data to the variable from a input text box but I am getting an error when I run the Movie. I have tried both a input text box and a Dynamic Text box, but they both produce the same error.
If I remove the data typing from the variable declaration the Movie runs and it updates the variable data but from all that I have read this is not a good practice.
I have attached the code, could someone Please help me out. I do not remember having these types of problems with ActionScript 2.
Thanks for the help.
Code:
var rectangle:Shape;
var thick :Number = 2; // line thickness
var color:Number= 0x000000; // Holds the color value
myButton_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
{
color = colorField_txt.text; (Line 11)
thick = lineThick_txt.text; (Line 12)
rectangle = new Shape();
rectangle.graphics.lineStyle(thick, color, .5);
rectangle.graphics.drawRect(10, 10, 100, 150);
addChild(rectangle);
}
myButton_btn.buttonMode = true;
ERROR MESSAGE:
1067: Implicit coercion of a value of type String to an unrelated type Number. (Refers to line 11)
1067: Implicit coercion of a value of type String to an unrelated type Number. (Refers to line 12)
Thanks again for any help.
Mike