获取舞台上的TextArea(通过ID、Name获取Child)
我试图在 FlashBuilder 上获取舞台上的 7 个 TextArea,它们的 id 均为“DES1”、“DES2”、“DES3”...并且名称相同“DES1”、“DES2”, “Desc3”...,但是当我尝试获取它时,我收到一个空对象的错误...
for(var i:int = 0;i<7;i++)
{
trace((stage.getChildByName("Desc"+(i+1))as TextArea).x);
}
我搜索了网络,但没有找到“getChildByID”的任何方法
I´m trying to get the 7 TextAreas on the stage on FlashBuilder,all of them have the id as "Desc1","Desc2","Desc3"... and the names are the same "Desc1","Desc2","Desc3"..., but when i try to get it,i get a error of a null object...
for(var i:int = 0;i<7;i++)
{
trace((stage.getChildByName("Desc"+(i+1))as TextArea).x);
}
I searched the web and dont find either any method of "getChildByID"
Flex ID 不适用于 getChildByName()。 getChildByName() 旨在处理 Adobe Flash CS 中嵌套元素的 id。
Flex id 是类成员的显式声明,其名称等于 id。
由于动作脚本语言中缺乏宏,您无法自动创建此类控件列表。
您可以手动创建文本区域的 Vector 或数组,并在代码的其他部分使用它来自动迭代 TextAreas:
或者您可以创建一个 Flex 数组:
Flex IDs don't work with getChildByName(). getChildByName() is designed to work with ids of nested elements in Adobe Flash CS.
An flex id is an explicit declaration of a class member with name which is equal to the id.
Due to the lack of macro in the actionscript laguage you cannot automate the creation of such lists of controls.
You can manually create an Vector or an Array of the text areas and use it in other part of your code to automatically iterate over your TextAreas:
Or you can create a flex Array: