簡體   English   中英

movieClip上的AS3 / TextField

[英]AS3 / TextField on movieClip

我有一個問題,盡管我可以使用此代碼,但是我不知道如何在不將它們放到舞台上的情況下為它們指定實例名稱。

MovieClipInstanceName.addChild(TextFieldInstanceName);

我不知道是否可能有另一種方法來將TextField獲取到movieClip。 我只能使用一幀和多個movieClips(頁面)。

實例名稱(您在Flash Professional IDE中定義)是自動創建的變量,其中存儲了指向對象的指針。 它還將字符串粘貼到具有相同值的對象屬性“名稱”。 在您的代碼中,這是您的“實例名稱”

var text1:TextField = new TextField();

將對象作為子對象添加到其他顯示對象與更改對象實例名稱無關,只是它們使用對象來定位此對象。

您對文本字段實例的引用為: text1 ,因此可以執行以下操作: mcInstanceName.addChild(text1); 如果變量text1在范圍內,則無需為其分配實例名稱。

如果確實要為其添加實例名稱,則可以這樣進行操作: text1.name = "myTextField"; 然后,您可以通過它引用此文本字段,只需記住您必須包括完整或相對路徑。 示例: root.mcInstanceName.myTextField.text = "This is some text"; //this would assume the mcInstanceName is on the main timeline and it cointains your textfield root.mcInstanceName.myTextField.text = "This is some text"; //this would assume the mcInstanceName is on the main timeline and it cointains your textfield

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM