005 獲取/設置TextField文本

Post date: 2012/11/22 上午 10:12:06

QQQQQQQQQQQQQQQQQQQQQQQ.

I have a new SWF file with Edit control. Maybe it’s just me or I didn’t copy enough codes or something.

I tried to follow the demos for your Unity Plug-in, ScaleForm.

What is the bare minimum code to show the keyboard on Mobile, get and set text in a text field?

Can you make sample project which only has 1 edit control (no animation, no extra, no buttons, no fancy stuff), that shows:

1) code to popup the keyboard on Android and iOS. I think it’s the same. If you have a normal SWF file with ClassicText, it does nothing. I added the Clik classes and no idea what’s wrong.

2) To set text from Unity3d to SWF’s text box

3) To get text from SWF to Unity3d.

AAAAAAAAAAAAAAAAAAAAAAAAAAA.

No code should be needed to display mobile keyboard entry when the user touches a text input box. Simply putting a Flash input textfield should pop up the mobile keyboard. Try changing Dynamic Text to Input Text. The HelloWorld demo shows a working text input box. There is a textfield that you can type a number into, then press the button next to it to rotate the camera. I can confirm this works on my Android as well as an iPad.

Setting text form Unity to a SWF is easy:

C#

private Value myTextField = null;
myTextField = myMovie.GetMember("myTF"); // myTF = instance name in Flash
myTextField.SetText("Whatever");

Getting text from SWF to Unity is also quite easy:

You can pass the text to a Unity function in ActionScript:

ExternalInterface.call("myUnityFunction", "some text");

C#

public void myUnityFunction(string param) {
    Debug.Log(param);
}

...or you can have Unity grab the text in C#:

private Value myTextField = null;
myTextField = myMovie.GetMember("myTF"); // myTF = instance name in Flash
Debug.Log(myTextField.GetMember("text")); // outputs whatever was entered into the textfield in Flash

Author: MatthewDoyleArt