View Single Post
Old 02-09-2012, 02:58 AM   PM User | #8
akuria
New Coder

 
Join Date: Nov 2011
Posts: 38
Thanks: 1
Thanked 0 Times in 0 Posts
akuria is an unknown quantity at this point
I got the slideshow to work. Now my next question is; how do you make it fade from image to image? right now one image fades out then the new image fades in with a delay between each image showing the white background each time. I want it to fade from one image to the other without the white of the background showing up.

Code:
<?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"
			   xmlns:fc="http://ns.adobe.com/flashcatalyst/2009" 
			   creationComplete="init()"
			   minWidth="546" 
			   minHeight="362">
	
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	
	<fx:Script>
		<![CDATA[
			import mx.effects.Fade;
			
			[Bindable]
			private var imageSource:String = "";
			
			private var pictures : Array = ["venue1.jpg","venue2.jpg","venue3.jpg","venue4.jpg","venue5.jpg","venue6.jpg","venue7.jpg","venue8.jpg","venue9.jpg","venue10.jpg","venue11.jpg","venue12.jpg","venue13.jpg","venue14.jpg","venue15.jpg","venue16.jpg","venue17.jpg","venue18.jpg"];
			private var index:int = 0;
			
			private function init():void{
				
				img.setStyle("completeEffect",Fade);
				imageSource = 'assets/' + pictures[index++];
				var timer:Timer = new Timer(4000);
				timer.addEventListener(TimerEvent.TIMER,changeImage);
				timer.start();
			}
			
			private function changeImage(e:TimerEvent):void{
				imageSource = ("assets/"+pictures[index++]);
				if(index>pictures.length -1) 
					index=0;
			}
		]]>
	</fx:Script>
	
	<mx:Image   source="{imageSource}" id="img" x="0" y="0" width="546"  height="362"/>
	
	
	
</s:Application>
akuria is offline   Reply With Quote