2013-10-07 37 views
0

我有一個名爲beta的包中的動作文件,其變量INSTANCE需要一個字符串。如果我在MXML中導入並聲明它爲alpha.beta.INSTANCE =「String」,它將運行並連接到實例字符串。我想將此綁定到MXML中的另一個輸入中,例如ID爲Foo的TextArea中的用戶輸入,但我得到錯誤1120訪問未定義屬性Foo。我知道這是簡單的我搞砸了,但我想我會問集體天才,因爲我沒有能夠在2天后找到正確的答案。發佈我嘗試過的不同方式而沒有成功。將變量分配給AS3中的事件

import alpha.beta; 
alpha.beta.INSTANCE = "String" //connects to the instance as String 

alpha.beta.INSTANCE = Foo.text //Error 1120 Access of Undefined Property Foo 

alpha.beta.INSTANCE = "{Foo.text}" //connects to a an instance with the name of literally {Foo.text} not the input values. In the sample below I would want it to connect to the 1 instance 


<s:TextArea id="Foo" text="1" /> 
+1

當你叫'Foo.text'? 'creationComplete'之後? –

+0

它給你一個錯誤,因爲在這種情況下,賦值階段發生在Foo組件被實例化之前。閱讀flex組件的生命週期。 – StephenNYC

回答

0

嘗試把代碼放在一個功能,如應用程序createComplete處理

private function creationCompleteHandler(e:Event):void { 
    alpha.beta.INSTANCE = Foo.text; 
}