在Actionscript数组中重命名字段的好方法?

时间:2021-01-04 18:58:36

Should be easy but google couldn't give me a straight answer. I have an array. The fields in the array have underscores that I would like to remove e.g. "Column_1" to "Column 1". Does anyone know a good way to do this without looping through the whole array and rebuilding it anew? I didn't see any methods in the reference that would make this easy. thx

应该很容易,但谷歌不能给我一个直接的答案。我有一个阵列。数组中的字段有下划线,我想删除,例如“Column_1”到“第1列”。有没有人知道这样做的好方法,而不需要遍历整个阵列并重新重建它?我没有在参考文献中看到任何方法可以使这很容易。谢谢

2 个解决方案

#1


Depending on where you are using this Array, you could use the labelFunction to format the data before presenting it. It is present in Lists, DataGrids and Trees.

根据您使用此数组的位置,您可以使用labelFunction在呈现数据之前格式化数据。它存在于列表,DataGrids和Trees中。

But you'd only need this if you have a very large data and wouldn't want to loop over all the records before showing them. A labelFunction would "reprocess" the label everytime before it's presented.

但是如果你有一个非常大的数据并且在显示它们之前不想遍历所有记录,你只需要这个。 labelFunction会在每次出现之前“重新处理”标签。

#2


Flex 3 has built in refactoring

Flex 3内置了重构功能

Edit... I may have misunderstood..

编辑......我可能误会了......

If you want to format the data in the array just loop through it and use regex to remove the underscores... or you can modify your query which grabs the data (if it is populated from a query)

如果你想格式化数组中的数据只是循环它并使用正则表达式删除下划线...或者你可以修改你的查询抓取数据(如果它是从查询填充)

#1


Depending on where you are using this Array, you could use the labelFunction to format the data before presenting it. It is present in Lists, DataGrids and Trees.

根据您使用此数组的位置,您可以使用labelFunction在呈现数据之前格式化数据。它存在于列表,DataGrids和Trees中。

But you'd only need this if you have a very large data and wouldn't want to loop over all the records before showing them. A labelFunction would "reprocess" the label everytime before it's presented.

但是如果你有一个非常大的数据并且在显示它们之前不想遍历所有记录,你只需要这个。 labelFunction会在每次出现之前“重新处理”标签。

#2


Flex 3 has built in refactoring

Flex 3内置了重构功能

Edit... I may have misunderstood..

编辑......我可能误会了......

If you want to format the data in the array just loop through it and use regex to remove the underscores... or you can modify your query which grabs the data (if it is populated from a query)

如果你想格式化数组中的数据只是循环它并使用正则表达式删除下划线...或者你可以修改你的查询抓取数据(如果它是从查询填充)