关于HorizontalList值绑定改变的问题。求解。
生活 2011-03-09 02:03:15 Main.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init();">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import asfiles.UserInfo;
import mx.collections.ArrayCollection;
[Bandable]
private var uInfo:UserInfo;
[Bandable]
private var arr:ArrayCollection = new ArrayCollection();
private function init():void
{
uInfo = new UserInfo();
uInfo.userName = "xiaowang";
uInfo.age = 25;
arr.addItem(uInfo);
}
private function updateArr():void
{
if(arr.length>0)
{
for(var i:int=0; i < arr.length;i++ )
{
var cu:UserInfo = arr[i] as UserInfo;
cu.userName = "xiaoli";
cu.age = 11;
}
}
}
]]>
</fx:Script>
<s:BorderContainer backgroundColor="0x000000">
<mx:HorizontalList id="horizontalList"
borderAlpha="0.0"
dataProvider="{arr}"
itemRenderer="faceimage"
labelField="label"
iconField="thumbnailImage"
liveScrolling="true"
columnWidth="175"
columnCount="3"
selectedIndex="0"
rowCount="1"
rowHeight="100"
showScrollTips="true"
horizontalScrollPolicy="on"
/>
</s:BorderContainer>
<s:Button x="361" y="185" label="update" click="updateArr();"/>
</s:Application>
UserInfo.as
package asfiles
{
public class UserInfo
{
public var userName:String;
public var age:int;
public function UserInfo()
{
}
}
}
faceimage.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" maxWidth="76" height="63" width="110">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label text="{data.userName}" x="17" y="35" height="24"/>
<s:Label text="{data.age}" x="17" y="10"/>
</mx:Canvas>
update按钮是更新信息,但是在HorizontalList里面的值就是不改变不知道什么情况,求救!