flex Repeater effert加效果

package cn.ishion.component
{
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import mx.core.IContainer;
	import mx.core.Repeater;
	import mx.events.ChildExistenceChangedEvent;
	import mx.events.FlexEvent;

	public class ConstomRepeater extends Repeater
	{
		private var showTimer:Timer;
		private var isEffert:Boolean=true;
		
		private var currentShowIndex:int=-1;
		public function ConstomRepeater()
		{
			super();
			this.addEventListener(FlexEvent.REPEAT_END,repeatEndHandler);
			showTimer=new Timer(1000);
			showTimer.addEventListener(TimerEvent.TIMER,startShow);
		
		}
		override public function initializeRepeater(ic:IContainer,recurse:Boolean):void{
			super.initializeRepeater(ic,recurse);
			if(ic){
				ic.addEventListener(ChildExistenceChangedEvent.CHILD_ADD,addChildHandler);
			}
			
			
		}
		private function addChildHandler(event:ChildExistenceChangedEvent):void{
				event.relatedObject.visible=false;
				trace("set date");
			}
		private function startShow(event:TimerEvent):void{
			var timer:Timer=event.target as Timer;
			try{
				trace(timer.currentCount);
				this.container.getChildAt(timer.currentCount-1).visible=true;
				
			}catch(e:Error){
				trace("error");
			}
			
		}
		override public function set dataProvider(value:Object):void{
			super.dataProvider=value;
			
		}
		/**
		 * 开始一个一个显示
		 * */
		private function repeatEndHandler(event:FlexEvent):void{
//			if(showTimer.running){
//				
//			}
			this.showTimer.repeatCount=this.container.numChildren;
			this.showTimer.reset();
			this.showTimer.start();
			
		}
		
	}
}

 示例

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
				layout="vertical"
				xmlns:component="cn.ishion.component.*">

	<mx:ArrayCollection id="images">
		<mx:Object src="@Embed('assert/7.jpg')">

		</mx:Object>
		<mx:Object src="@Embed('assert/7.jpg')">

		</mx:Object>
		<mx:Object src="@Embed('assert/7.jpg')">

		</mx:Object>
		<mx:Object src="@Embed('assert/7.jpg')">

		</mx:Object>
		<mx:Object src="@Embed('assert/7.jpg')">

		</mx:Object>
	</mx:ArrayCollection>

	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import flash.utils.clearInterval;
			import flash.utils.setInterval;
			import mx.events.ChildExistenceChangedEvent;
			import mx.core.Container;
			import mx.containers.HBox;


			private function changeDate():void
			{

				rep.dataProvider=images;

			}
			import mx.effects.easing.Elastic
		]]>
	</mx:Script>


	<mx:Zoom id="zoom"
			 zoomWidthFrom="0.1"
			 zoomWidthTo="1"
			 zoomHeightFrom="0.1"
			 zoomHeightTo="1"
			 easingFunction="Elastic.easeOut">

	</mx:Zoom>
	<mx:HBox id="hb">
		<component:ConstomRepeater id="rep"
								   dataProvider="{images}">
			<mx:Image source="{rep.currentItem.src}"
					  scaleY="0.1"
					  scaleX="0.1"
					  visible="false"
					  showEffect="{zoom}"/>
		</component:ConstomRepeater>
	</mx:HBox>
	<mx:Button click="changeDate()">

	</mx:Button>

</mx:Application>
 

你可能感兴趣的:(xml,Flex,Flash,Adobe)