在 List 中执行 getItemAt() 时获取 [Object Object]
我已将我的数据提供程序设置为Bindable
,如下所示:
[Bindable]
public var dataProvider:ArrayCollection;
public function init():void{
dataProvider = new ArrayCollection(
[{label:"x"},
{label:"y"},
{label:"z"}]);
然后在按钮的 CLick 事件调用的函数中,我想获取特定索引处的项目
private function getmyItem(event:Event):void {
trace(dataProvider.length);
trace(dataProvider.getItemAt(1));
//OR
trace(dataProvider.getItemAt(myList.selectedIndex));
}
但我得到 [Object Object ]
在我的踪迹中。有人可以告诉我我的代码有什么问题吗?
谢谢
I have set my data provider as Bindable
as such:
[Bindable]
public var dataProvider:ArrayCollection;
public function init():void{
dataProvider = new ArrayCollection(
[{label:"x"},
{label:"y"},
{label:"z"}]);
Then in a function called upon CLick event of a button, I want to get the item at a particular index
private function getmyItem(event:Event):void {
trace(dataProvider.length);
trace(dataProvider.getItemAt(1));
//OR
trace(dataProvider.getItemAt(myList.selectedIndex));
}
But I am getting [Object Object]
in my trace. Can someone tell me what is the prob with my code?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的代码不完整
your code is not complete
您想在
trace
中获得什么并不明显,但我可以猜测以下修复可以解决您的问题:It is not any obvious what do you want to get in
trace
but I can guess the following fixes can solve your problem:这些是使用
{}
语法创建的对象
。These are
Objects
created using{}
syntax.