flex 让datagrid中的某一列闪动提示
现在需求是如果新增一条数据就闪动显示我现在数据能自动刷新但不知道怎么做闪动?只要某一列闪动不是整个datagrid全闪动例子在student类中如果id=1的话就闪动23...
现在需求是如果新增一条数据就闪动显示 我现在数据能自动刷新 但不知道怎么做闪动?只要某一列闪动不是整个datagrid全闪动 例子在student类中 如果id=1 的话就闪动 2313586475@qq.com 求大神
展开
1个回答
展开全部
基本实现了一下,效果不是很好。我这实现的是行闪动,要是实现列闪动就override drawColumnBackground()
mxml文件
存在问题:1、timer启停问题,两个控件时间间隔不能相同,要不就看不出来效果
2、选中行问题,在例子中没有同时显示多行没有实现
3、没有添加透明度效果
4、drawRowBackground中sprite参数的选取
希望对你有帮助
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
xmlns:sq="sq.*"
creationComplete="Init()" xmlns:comp="comp.*" minWidth="1024" minHeight="900" verticalScrollPolicy="off"
>
<mx:Script>
<![CDATA[
import flash.trace.Trace;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.ListEvent;
private var shape:Shape;
public var dataArray:ArrayCollection = new ArrayCollection;
private function Init():void{
dataArray.addItem({name:'张三',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'里斯',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'王五',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'赵六',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'小七',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'张三',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'里斯',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'王五',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'赵六',phone:'2270',email:'12@123.com'});
dataArray.addItem({name:'小七',phone:'2270',email:'12@123.com'});
dgId.dataProvider = dataArray;
}
]]>
</mx:Script>
<sq:SQDataGrid id="dgId" x="10" y="10" width="450" height="400" fontSize="12">
</sq:SQDataGrid>
<mx:HBox y="300">
</mx:HBox>
</mx:Application>
as文件
package sq{
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
import mx.controls.DataGrid;
public class SQDataGrid extends DataGrid
{
public function SQDataGrid()
{
super;
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER,timerHandler);
myTimer2.start();
myTimer2.addEventListener(TimerEvent.TIMER,timerHandler2);
}
protected override function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
{
if(dataProvider&&dataIndex < (dataProvider as ArrayCollection).length){
if(mm==1){
sprite =s;
trace("sa"+s.height)
}
mm++;
//代码判断出可以取dataProvider 的数据来判断要改变什么颜色
var item:Object = (dataProvider as ArrayCollection).getItemAt(dataIndex);
super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);
}
}
private function timerHandler(e:TimerEvent):void{
if(dataProvider){
var len:int = (dataProvider as ArrayCollection).length;
for(var i:int = 0 ;i<len;i++){
var item:Object = (dataProvider as ArrayCollection).getItemAt(i);
if( item.name =="张三" )
{
trace("1 i"+i)
colorData=0xFF1200;
drawRowBackground(sprite,i,30*i-3,30,colorData,i);
}else{
colorData=0x000000;
}
}
}
}
private function timerHandler2(e:TimerEvent):void{
var len:int= (dataProvider as ArrayCollection).length;
for(var j:int = 0 ;j<len;j++){
var item:Object = (dataProvider as ArrayCollection).getItemAt(j);
if( item.name =="张三" )
{
trace("2 j"+ j)
colorData=0x000000;
drawRowBackground(sprite,j,30*j-3,30,colorData,j);
}else{
colorData=0x000000;
}
}
}
private var delay:uint = 123;
private var delay2:uint = 555;
private var repeat:uint = 10000;
private var repeat2:uint = 10000;
private var myTimer:Timer = new Timer(delay, repeat);
private var myTimer2:Timer = new Timer(delay2, repeat2);
private var indexData:int=0;
private var sprite:Sprite;
private var colorData:uint = 0;
private var mm:int =0;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询