首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

有关list效果的难题,应该是超难的有关问题吧

2012-02-11 
有关list效果的难题,应该是超难的问题吧下面代码中有两个LIST,一个BUTTON。点击BUTTON时为数据源啬增加一项

有关list效果的难题,应该是超难的问题吧
下面代码中有两个LIST,一个BUTTON。点击BUTTON时为数据源啬增加一项,两个LIST里的内容也都增加一项。当第一次点击时是正常的两个LIST都能显示出效果。但当第二次点击时,两个LIST的效果都没了。
但是若将第二个LSIT删除,这时无论点击多少次,唯一的这个LSIT中始终能正常显示效果。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:DefaultListEffect color="0xccccff" fadeOutDuration="2000" id="glow"/>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="900" top="20" left="20">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
//note that for this example to work, the dataprovider
//must be an array collection
[Bindable]
privatevardp:ArrayCollection = new ArrayCollection([{name:"John Smith",position:"developer"}, 
{name:"Ellen Smith",position:"manager"}, 
{name:"James Smith",position:"accountant"}, 
{name:"Jane Smith",position:"designer"}]);
privatefunction addItem():void
{
dp.addItem({name:"Jim Smith", position:"Janitor"});
}
]]>
</mx:Script>

<mx:List width="300" itemsChangeEffect="{glow}"dataProvider="{dp}" editable="true" labelField="name"/>
<mx:Button click="addItem()" label="add item"/>
<mx:List width="300" itemsChangeEffect="{glow}"dataProvider="{dp}" editable="true" labelField="name"/>
</mx:VBox>
</mx:Application>

[解决办法]
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:DefaultListEffect color="0xccccff"
fadeOutDuration="2000"
id="glow"/>
<mx:DefaultListEffect color="0xccccff"
fadeOutDuration="2000"
id="glow1"/>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
width="400"
height="900"
top="20"
left="20">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
//note that for this example to work, the dataprovider
//must be an array collection
[Bindable]
private var dp:ArrayCollection=new ArrayCollection([{name: "John Smith", position: "developer"}, {name: "Ellen Smith", position: "manager"}, {name: "James Smith", position: "accountant"}, {name: "Jane Smith", position: "designer"}]);

private function addItem():void
{
dp.addItem({name: "Jim Smith", position: "Janitor"});
}
]]>
</mx:Script>

<mx:List width="300"
itemsChangeEffect="{glow}"
dataProvider="{dp}"
editable="true"
labelField="name"/>
<mx:Button click="addItem()"
label="add item"/>
<mx:List width="300"
itemsChangeEffect="{glow1}"
dataProvider="{dp}"
editable="true"
labelField="name"/>
</mx:VBox>
</mx:Application>


这样就可以了.
DefaultListEffect 是不是不能同时作用俩个list.

但为什么第一次可以?(以后就显示不效果了)

热点排行