views:

42

answers:

1

Hello guys, I'm starting with AS3, i have a problem. I have a button, and inside the button i have a dynamic text field. The button is inside of a movieclip, the instance name of it is News, the instance name of the button is collegamento and the instance name of the dynamic text is Testo. So knowing this I'm triyng to change the content of the text using:

News.collegamento.Testo.htmlText="text here";

But Flash is giving me this error:

ReferenceError: Error #1069: Property Testo not found on flash.display.SimpleButton and there is no default value. at app_fla::MainTimeline/parseXML()[app_fla.MainTimeline::frame1:21] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()

Any ideas of how to solve it? Thanks!

+2  A: 

I am afraid you can't change the text value of a dynamic textfield in a SimpleButton. You will have to make it a MovieClip instead. The reason is that the SimpleButton does not inherit from Sprite but DisplayObject instead.

EDIT: Actually i did find that there is a hack way to do it:

var upState:DisplayObjectContainer = myBtn.upState as DisplayObjectContainer;
var myTxt:TextField  = upState.getChildAt(1) as TextField;
myTxt.text = "hack";

do this for each state I guess

Allan