display input text in ein anderes Textfeld in flash as3
Bitte helfen Sie mir...
Ich versuche zu zeigen, die Eingabe von text zu einem anderen text-Feld zur Laufzeit. Ich will zeigen das
myOutputBox
mit in einem Film-clip. Der code ist unten:
Actionscript 3
package
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.text.*;
import flash.events.*;
public class CaptureUserInput extends Sprite
{
private var myTextBox:TextField = new TextField();
private var myOutputBox:TextField = new TextField();
private var myText:String = "Type your text here.";
public function CaptureUserInput()
{
captureText();
}
public function captureText():void
{
myTextBox.type = TextFieldType.INPUT;
myTextBox.background = true;
addChild(myTextBox);
myTextBox.text = myText;
myTextBox.addEventListener(TextEvent.TEXT_INPUT, textInputCapture);
}
public function textInputCapture(event:TextEvent):void
{
var str:String = myTextBox.text;
createOutputBox(str);
}
public function createOutputBox(str:String):void
{
myOutputBox.background = true;
myOutputBox.x = 200;
addChild(myOutputBox);
myOutputBox.text = str;
}
}
}
Ist
CaptureUserInput
Ihre document-Klasse? Auch, wo hast myTextBox
und myOutputBox
kommen?
InformationsquelleAutor user1626744 | 2011-10-10
Du musst angemeldet sein, um einen Kommentar abzugeben.
Feste ein wenig, Ihren code, und hat ein paar Sachen, hoffe das hilft dir:
Ja, natürlich, ändern Sie einfach die addChild innerhalb der Funktion createOutputBox (): my_movieclip.addChild(muyOutputBox). Nur stellen Sie sicher my_movieclip existiert grafisch! (oder erklären und hinzufügen von code). Wenn Sie mir sagen, wo wird dieser MovieClip kommen, ich werde zu aktualisieren, den Antwort-code.
InformationsquelleAutor danii