Alph
Alph

Reputation: 1

Flash AS3. Changing the text inside a movieclip within it's own class file

I have a movieclip with a dynamic text embedded to only accept numerals.

What I'm trying to do is to give it it's own class that for everytime the movieclip is added on the stage the value written on its text box will be 2, but it's giving me the error:

Implicit coercion of a value of type int to an unrelated type String.

I'm fairly new to AS3 so I'm not sure what's wrong.

Here's the part of my codes that I want to fix:

private function onAddedToStage(event:Event):void
{
    my_value.text = 2; //should change the value written on the textbox.

    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}

Thanks in advance! :)

Upvotes: 0

Views: 85

Answers (1)

Nicola Valcasara
Nicola Valcasara

Reputation: 113

You are giving an Int when he is asking a String. It should be

my_value.text = "2";

but, why you need to hard code his value? can't you simple initialize the value of the textbox to be 2 directly within the property of the embedded textbox?

Upvotes: 1

Related Questions