【发布时间】:2011-09-29 05:57:13
【问题描述】:
(大神帮我在 AS2 中编程)
我正在遍历一组文本字段对象,并在按下 Tab 时跟踪选定的焦点字段以及每个对象。
我试图将这些对象等同起来,但尽管它们追踪的完全相同,但它们却不是。
m_InputFieldsArray = new Array(m_TitleTextInput, m_CommentsTextArea, m_EmailTextInput);
for (var i:Number = 0; i < m_InputFieldsArray.length; i++)
{
trace("Get Focus: " + Selection.getFocus());
trace("Arr Index: " + m_InputFieldsArray[i].textField);
if (Selection.getFocus() == m_InputFieldsArray[i].textField)
{
trace("Match!");
return;
}
else
{
trace("NO Match!");
}
}
输出:
Get Focus: _level0.m_Window.form.m_TitleTextInput.textField
Arr Index: _level0.m_Window.form.m_TitleTextInput.textField
NO Match!
Get Focus: _level0.m_Window.form.m_TitleTextInput.textField
Arr Index: _level0.m_Window.form.m_CommentsTextArea.textField
NO Match!
Get Focus: _level0.m_Window.form.m_TitleTextInput.textField
Arr Index: _level0.m_Window.form.m_EmailTextInput.textField
NO Match!
第一组轨迹相同,但显然它们不匹配。 Selection.getFocus() 返回一个字符串,而数组索引正在跟踪文本字段对象。如果我将toString() 添加到文本字段对象,它将跟踪为[Object object]
我怎样才能完成比赛?
【问题讨论】:
-
m_TitleTextInput和其他组件? -
是的,它们是定制的 Scaleform 组件。
标签: actionscript match trace