Flex ArrayCollection - 访问对象方法/属性?
也许我没有得到 ArrayCollection 的真正含义,但首先是一些代码
public var test1:AkwRep = new AkwRep(1,200,200,2,86,2010,2012,334342,"Typ","Standort","Testname","url","owner",true);
// Objekte in ein Array
public var akwArray:Array = new Array(15);
public function addAkw():void {
akwArray[0] = test1;
}
public var akwList:ArrayCollection = new ArrayCollection(akwArray);
(akw 意味着 Atomkraftwerk -> 核电站;))
所以我有一个带有 akwRep-Objects 的数组。对于数据绑定,我将其放入 ArrayCollection 中。 到目前为止没有问题。但现在我想做一些类似的事情
<s:Label text={akwList.getItemAt(0).getAkwName()} />
,而 getAkwName 是 AkwRep.as 中的一个方法,它返回一个字符串。但这不起作用 - 我无法通过 ArrayCollection 访问任何方法或属性。
有解决办法吗?如果我尝试使用数组,flexbuilder 说他无法使用 akwArray[0] 进行数据绑定...
编辑:一些新代码
这位于我的 main 中的
标记中应用程序
[Bindable]
// AKW-Objekte erstellen
public var test1:AkwRep = new AkwRep(1,200,200,2,86,2010,2012,334342,"Typ","Standort","Testname","url","owner",true);
[Bindable]
// Objekte in ein Array
public var akwArray:Array = new Array(15);
public function addAkw():void {
akwArray[0] = test1;
}
[Bindable]
public var akwList:ArrayCollection = new ArrayCollection(akwArray);
public function init():void{
trace(akwList.getItemAt(0));
}
,这是我的 AkwRep.as
public class AkwRep
{
// Attribute
// some more attributes right here
public var typ:String;
public var standort:String;
private var akwName:String;
[Bindable]
public function get AkwName():String {
return this.akwName;
}
// Konstruktoren
public function AkwRep(id:Number, x:Number, y:Number, alter:Number, amNetz:Number, offOhneVerl:Number, offMitVerl:Number, leistung:Number, typ:String, standort:String, akwName:String, wikiurl:String, owner:String, moratorium:Boolean) [...]
Maybe i didn't get the real meaning of the ArrayCollection, but first of all some code
public var test1:AkwRep = new AkwRep(1,200,200,2,86,2010,2012,334342,"Typ","Standort","Testname","url","owner",true);
// Objekte in ein Array
public var akwArray:Array = new Array(15);
public function addAkw():void {
akwArray[0] = test1;
}
public var akwList:ArrayCollection = new ArrayCollection(akwArray);
(akw means Atomkraftwerk -> nuclear power plant ;) )
so i've got an array with akwRep-Objects. For databinding i put it into a ArrayCollection.
No problems so far. But now i want to do something like
<s:Label text={akwList.getItemAt(0).getAkwName()} />
while getAkwName is a method in AkwRep.as which returns a string. but this didn't work - I can not acces any methods or attributes via ArrayCollection.
Is there a solution? If i try it with the array, flexbuilder says he can't do databinding with akwArray[0] ...
Edit: some new code
This is in the <fx:script>
tag in my main app
[Bindable]
// AKW-Objekte erstellen
public var test1:AkwRep = new AkwRep(1,200,200,2,86,2010,2012,334342,"Typ","Standort","Testname","url","owner",true);
[Bindable]
// Objekte in ein Array
public var akwArray:Array = new Array(15);
public function addAkw():void {
akwArray[0] = test1;
}
[Bindable]
public var akwList:ArrayCollection = new ArrayCollection(akwArray);
public function init():void{
trace(akwList.getItemAt(0));
}
and this is my AkwRep.as
public class AkwRep
{
// Attribute
// some more attributes right here
public var typ:String;
public var standort:String;
private var akwName:String;
[Bindable]
public function get AkwName():String {
return this.akwName;
}
// Konstruktoren
public function AkwRep(id:Number, x:Number, y:Number, alter:Number, amNetz:Number, offOhneVerl:Number, offMitVerl:Number, leistung:Number, typ:String, standort:String, akwName:String, wikiurl:String, owner:String, moratorium:Boolean) [...]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 MXML 中
在 AkwRep.as 中
In MXML
In AkwRep.as