2010-10-11 42 views
1

我從AS3開始,遇到問題。我有一個按鈕,並在按鈕內有一個動態文本字段。該按鈕位於動畫片段內,其實例名稱爲News,按鈕的實例名稱爲collegamento,動態文本的實例名稱爲Testo。因此,瞭解這個我triyng改變使用文本的內容:我不能在ActionScript 3中更改按鈕內動態文本的內容

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

但是Flash是給我這個錯誤:

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()

如何解決它的任何想法?謝謝!

回答

2

恐怕您無法更改SimpleButton中動態文本字段的文本值。您必須改爲使用MovieClip。原因是SimpleButton不是從Sprite繼承而是從DisplayObject繼承的。

編輯: 其實我沒有發現有黑客攻擊的方式來做到這一點:

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

每個國家做到這一點我想