我想将一组舞台上的movieclip实例放入一个数组中,但我得到的是对象MovieClip而不是实例名称。有任何想法吗?感谢。
// When the "Convert" Button is pressed...
public void convertUnits(View view) {
Button convert = (Button) findViewById(R.id.buttonConvert);
EditText inputField = (EditText) findViewById(R.id.editText);
EditText showConvertion = (EditText) findViewById(R.id.editText2);
// This variable is what number the user enters
double userInput = Double.parseDouble(inputField.getText().toString().trim());
// Radio Buttons variables on *LEFT SIDE*
RadioButton leftMillimeters = (RadioButton) findViewById(R.id.leftMM);
// Radio Buttons variables on *RIGHT SIDE*
RadioButton rightMillimeters = (RadioButton) findViewById(R.id.radioButton9);
if (inputField.getText().toString().trim().length() == 0) {
// Shows Error messages to user if s/he didn't put a number in the textField -- "userInput"
Context context = getApplicationContext();
CharSequence text = "Text field is empty!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
inputField.setError("Please enter a number to convert");
return;
} else {
// The math for conversions
// Millimeter to Millimeter
double milToMilResult = userInput * 1;
String milToMilString = Double.toString(milToMilResult);
// If the user's unit is Millimeters then...
if (leftMillimeters.isChecked()) {
// To Millimeters
if (rightMillimeters.isChecked()) {
showConvertion.setText(milToMilString);
}
}
}
}
跟踪给了我: [对象MovieClip],[对象MovieClip]
代替: puz1.wMc,puz1.aMc
答案 0 :(得分:1)
访问MovieClip的实例,将MovieClip作为MovieClip
类型的对象。
如果您想要MovieClip对象的名称,只需使用.name
对象的MovieClip
属性。
试试这个:
var puz1_arr:Array = new Array (puz1.wMc.name, puz1.aMc.name);
trace(puz1_arr);
这假设puz1.wMc
和puz1.aMc
是MovieClip
个对象。
参考: