header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Priyanka Kshirsagar
Points:0
Posts:0

8/31/2010 5:07:50 AM

Title: Scrolling images in flex


I creat one image gallery in flex For that I use horizontallist component.Now I have to move these images from left to right and right to left.All images are come from one XML file.I know only that i have to use Tween class for that but how don't know.so can you please tell me with code?It is more helpful.



1
Warrior
Points: 420
Posts:0
8/31/2010 12:11:43 PM



check this buddy this is a image gallery with tween effect and can move to right or left as you require

http://www.flexer.info/2008/05/29/image-gallery-component-imagerail/

2
Priyanka Kshirsagar
Points: 0
Posts:0
8/31/2010 9:17:37 PM



I was do that one already.I want continuous scrolling images.
which you provide as a solution the scrolling depends on next,previous buttons.
I don't want that.I want continuous scrolling of image without using button.
If you provide me that one is more useful.
Anyways Thanks for reply.

3
Rayan
Points: 690
Posts:0
8/31/2010 9:52:34 PM



see this , a complete example of continuous scrolling image gallery in flash with source code in actionscript 3.

http://tutorials.flashmymind.com/2009/04/infinite-gallery-menu/comment-page-1/#comment-32816

4
cf_flex
Points: 240
Posts:0
9/1/2010 1:00:02 AM



try out this one without using tween class or flash



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" 
	horizontalScrollPolicy="off" verticalScrollPolicy="off">
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.rpc.events.ResultEvent;
			import mx.rpc.events.FaultEvent;
			import flash.events.MouseEvent;
			
			
			private var goLeft:Boolean = false;
			private var goRight:Boolean = false;
						
			private function init():void {
				getData.send();
				createTimer();
			}
			
			private function httpresult(event:ResultEvent):void{
	    		//ur data
			}
	    	
			private function httpfault(event:FaultEvent):void{
	    		
	    	}
			
			private function createTimer():void {
	            var myTimer:Timer = new Timer(30);
	            myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
	            myTimer.start();
	            gallery2.move(1638,0);
	        }
	        
	        private function timerHandler(event:TimerEvent):void {
				if(goLeft){
	            	moveRight();
	        	}
	        	if(goRight){
	            	moveLeft();
	        	}
	        }
			
			private function moveLeft():void{
				gallery1.move(gallery1.x-10,0);
				gallery2.move(gallery2.x-10,0);					
								
				if(gallery1.x<-1638){
					gallery1.x=gallery2.x+gallery1.width;
				}else if(gallery2.x<-1638){
					gallery2.x=gallery1.x+gallery2.width;
				}				
			}

			private function moveRight():void{
				gallery1.move(gallery1.x+10,0);
				gallery2.move(gallery2.x+10,0);					
								
				if(gallery1.x>1638){
					gallery1.x=gallery2.x-gallery1.width;
				}else if(gallery2.x>1638){
					gallery2.x=gallery1.x-gallery2.width;
				}
			}

	    ]]>
    </mx:Script>
	<mx:HTTPService id="getData" url="ur xml file path.xml" result="httpresult(event)" fault="httpfault(event)" resultFormat="e4x"/>
		
	<mx:HBox id="gallery1" height="115" width="100%" y="0" verticalAlign="middle" horizontalAlign="center" 
    	horizontalGap="0">
		<mx:Repeater id="imgrp1" dataProvider="{}"> <!--httpresult as dataprovider-->
			<mx:Image id="imageList" source="{imgrp1.currentItem.mediahubthumbnail}"/>
		</mx:Repeater>
	</mx:HBox>
	
	<mx:HBox id="gallery2" height="115" width="100%" y="0" verticalAlign="middle" horizontalAlign="center" 
    	horizontalGap="0">
		<mx:Repeater id="imgrp2" dataProvider="{}"> <!--httpresult as dataprovider-->
			<mx:Image id="imageList2" source="{imgrp2.currentItem.mediahubthumbnail}"/>
		</mx:Repeater>
	</mx:HBox>

	<mx:VBox id="leftbox" left="0" top="0" height="95" width="25" verticalAlign="middle"
		mouseOver="goLeft=true;" mouseOut="goLeft=false;"  backgroundColor="#B7BABC" backgroundAlpha="0.25">
		<mx:Image source="assets/leftArrow.gif"/>
	</mx:VBox>
	<mx:VBox id="rightbox" right="0" height="95" width="25" verticalAlign="middle" 
		mouseOver="goRight=true;" mouseOut="goRight=false;"  backgroundColor="#B7BABC" backgroundAlpha="0.25" top="0">	
		<mx:Image source="assets/rightArrow.gif"/>
	</mx:VBox>

</mx:Application>



5
Priyanka Kshirsagar
Points: 0
Posts:0
9/1/2010 10:58:30 PM



Hi cf_flex,

I can't understand this source="{imgrp1.currentItem.mediahubthumbnail}"
In which i understand only imgrp1 is the id or repeater but not understand
currentItem.mediahubthumbnail
so please reply me.

6
Priyanka Kshirsagar
Points: 0
Posts:0
9/1/2010 11:00:33 PM



Hi Rayan,

You give me good solution but all my images are come from one xml file.
so can you tell me how I solve this problem?

7
cf_flex
Points: 240
Posts:0
9/1/2010 11:05:39 PM



hi priyanka,

currentItem : The item in the dataProvider currently being processed while this Repeater is executing

mediahubthumbnail:node name of the xml which is holding the image path/location

if u can post a general structure of the ur xml ,can explain u better


8
cf_flex
Points: 240
Posts:0
9/1/2010 11:16:18 PM



basically what i am doing in scrolling images example is that ,i have taken 2 hbox with the images which would be loaded from the xml file and both the boxes hold the same images. once the first box completes the second box comes into picture and both the boxes loop in clockwise and anticlockwise directions.

go thru these links might be helpful
http://askmeflash.com/qdetail/742/how-to-repeat-the-images-in-a-horizontal-list

http://joelhooks.com/2009/12/24/continuous-scrolling-thumbnail-component-for-flex/

9
Priyanka Kshirsagar
Points: 0
Posts:0
9/1/2010 11:29:49 PM



Hi cf_flex,

I am forward you my xml and structure is as follow:
<?xml version="1.0"?>
<gallery>
<movie>
<pic>titanic.jpg</pic>
<title>Titanic</title>
<date>1997</date>
</movie>
<movie>
<pic>shakespeareinlove.jpg</pic>
<title>Shakespeare in Love</title>
<date>1998</date>
</movie>
<movie>
<pic>americanbeauty.jpg</pic>
<title>American Beauty</title>
<date>1999</date>
</movie>
<movie>
<pic>gladiator.jpg</pic>
<title>Gladiator</title>
<date>2000</date>
</movie>
<movie>
<pic>beautifulmind.jpg</pic>
<title>A Beautiful Mind</title>
<date>2001</date>
</movie>
<movie>
<pic>chicago.jpg</pic>
<title>Chicago</title>
<date>2002</date>
</movie>
<movie>
<pic>lordoftherings.jpg</pic>
<title>The Lord of the Rings: The Return of the King</title>
<date>2003</date>
</movie>
<movie>
<pic>milliondollarbaby.jpg</pic>
<title>Million Dollar Baby</title>
<date>2004</date>
</movie>
<movie>
<pic>crash.jpg</pic>
<title>Crash</title>
<date>2005</date>
</movie>
<movie>
<pic>thedeparted.jpg</pic>
<title>The Departed</title>
<date>2006</date>
</movie>
<movie>
<pic>nocountryforoldmen.jpg</pic>
<title>No Country for Old Men</title>
<date>2007</date>
</movie>
<movie>
<pic>slumdogmillionaire.jpg</pic>
<title>Slumdog Millionaire</title>
<date>2008</date>
</movie>
</gallery>

10
Priyanka Kshirsagar
Points: 0
Posts:0
9/2/2010 12:15:46 AM



Hi cf_flex,

Below code is my gallery.mxml page code. I want when I click on next button the list moves slowly or on mouse over. The first link which u provide me I was install all the code but it's not working properly. when I mouseover on third on image it jumps on directly last page of image. I don't want that. Please provide me solution.


<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="service.send()" height="536" width="852">
	
	
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import mx.rpc.events.ResultEvent;
			import mx.controls.Image;
			import mx.managers.PopUpManager;
			import mx.events.ResizeEvent;
			import mx.events.ListEvent;
			
			 private var fullImg:Image;
				
			[Bindable]
			private var movies:ArrayCollection;
			
			 
             private function init(obj:Object = null):void {
                if (obj == null) {
                	//lbl.title="";
                    img.source = null;
                } else {
                	//lbl.title = String("assets/poster/"+obj.title).toUpperCase();
                    img.source = "assets/poster/"+obj.pic;
                }
               // moviesList.addEventListener(MouseEvent.MOUSE_MOVE,scrollList);
            } 

            private function horizontalList_change(evt:ListEvent):void {
                init(evt.target.selectedItem);
            }

			//rollout Function
            private function horizontalList_itemRollOut(evt:ListEvent):void {
                if (moviesList.selectedIndex == -1) {
                    init(null);
                } else {
                    init(moviesList.selectedItem);
                }
            }
            
            //rollover Function
             private function horizontalList_itemRollOver(evt:ListEvent):void {
                init(evt.itemRenderer.data);
            }
			
			//previous button on
			 private function prev():void {
                var pos:int = moviesList.horizontalScrollPosition-4;
                var min:int = 0;
                var value:int = Math.max(min, pos);
                moviesList.horizontalScrollPosition = value;
            }
			
			//next button on
            private function next():void {
                var pos:int = moviesList.horizontalScrollPosition+4;
                var max:int = moviesList.maxHorizontalScrollPosition;
                var value:int = Math.min(pos, max);
                moviesList.horizontalScrollPosition = value;
            }


			private function serviceHandler(event:ResultEvent):void{
				movies = event.result.gallery.movie;
			}
		]]>
	</mx:Script>

	<mx:HTTPService id="service" url="xml/data.xml" result="serviceHandler(event)"/>
	<mx:VBox height="503" width="827">
		<mx:HBox width="820">
	<mx:Image id="previous" source="assets/previous.png" click="prev();"/>	
	<mx:HorizontalList id="moviesList" dataProvider="{movies}"   
		rowHeight="160" columnWidth="180" columnCount="4" horizontalScrollPolicy="off" 
		change="horizontalList_change(event);"
        itemRollOver="horizontalList_itemRollOver(event);"
        itemRollOut="horizontalList_itemRollOut(event);">
		<mx:itemRenderer>
			<mx:Component>
				<mx:VBox horizontalAlign="center" verticalAlign="middle">
					<mx:Image   source="assets/thumb/{data.pic}"/>
					<mx:Label text="{data.date}" color="#000000" fontStyle="italic"  />
				</mx:VBox>
			</mx:Component>
		</mx:itemRenderer>
	</mx:HorizontalList>
		<mx:Image id="next1" source="assets/next.png" click="next();"  height="38"/>
	</mx:HBox>
		<mx:VBox width="476" height="301">
			<mx:Image id="img" scaleContent="true"
                horizontalCenter="0"
                verticalCenter="0"
                maintainAspectRatio="true"
                width="250"
                height="250"
                completeEffect="Fade"
		showBusyCursor="true" horizontalAlign="right"/>
	<mx:Label id="lbl" text="{moviesList.selectedItem.title} ({moviesList.selectedItem.date})" 
		fontFamily="Arial" fontSize="12" fontWeight="bold" color="#FFFFFF" textAlign="right" width="256"/>
		</mx:VBox>
		
	</mx:VBox>
	
</mx:Canvas>


11
Bla
Points: 0
Posts:0
12/22/2010 9:43:36 AM



use a button instead of an image embed the image that u want to use on that button and use the property autorepeat and the event buttonDown:

<mx:Button id="btnLeftArrow" downSkin="@Embed('/assets/previous.png')"
overSkin="@Embed('/assets/previous.png')" upSkin="@Embed('/assets/previous.png')" autoRepeat="true" buttonDown="prev()" />

it should work with that and thanks your code help me a lot.

12
nishit
Points: 0
Posts:0
7/23/2011 12:02:17 AM



data.xml file

<?xml version="1.0"?>
<album last_page="loop">
	<slide>
		<source>assets/alcatraz.jpg</source>
		<caption>Alcatraz</caption>
		
	</slide>
	<slide>
		<source>assets/bourbonstreet.jpg</source>
		<caption>Bourbonstreet</caption>
	</slide>
	<slide>
		<source>assets/buckinghampalace.jpg</source>
		<caption>Buckinghampalace</caption>
	</slide>
	<slide>
		<source>assets/coittower.jpg</source>
		<caption>Coittower</caption>
	</slide>
	<slide>
		<source>assets/elcapitan.jpg</source>
		<caption>Elcapitan</caption>
	</slide>
	<slide>
		<source>assets/fishermanswharf.jpg</source>
		<caption>Fisherman</caption>
	</slide>
	<slide>
		<source>assets/lombardstreet.jpg</source>
		<caption>Lombardstreet</caption>
	</slide>
</album>

//slideshow.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
	creationComplete="service.send()" xmlns:ns1="component.*">
	<mx:Style source="style.css">
		
		
	</mx:Style>
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.events.CollectionEvent;
			import mx.effects.effectClasses.WipeRightInstance;
			import mx.effects.WipeLeft;
			import mx.effects.WipeRight;
			import mx.managers.PopUpManager;
			import component.window;
			import mx.collections.ArrayCollection;
			import mx.rpc. events.ResultEvent;
				
				public var xmldata:XML;
				public var app:Application;
				
				[Bindable]
				public var curslide:Object;
				
				[Bindable]
				public var pictures:ArrayCollection;
				
				[Bindable]
				private var curindex:int=0;
				
				public var lastpage:String;
				
				
				private function resulthandler(event:ResultEvent):void
				{
					maintext.setStyle("completeEffect",WipeLeft);
					mainimg.setStyle("completeEffect",WipeRight);
					
					pictures = event.result.album.slide;
					pictures = event.result.album.last_page;
				}
				
				public var winPop:window = new window();
				private function popFun(event:MouseEvent):void
				{
					
	               		 	 winPop.sourceimage = event.currentTarget.source; 
	               			winPop.index=curindex;
	               		 	 	               		 
               			PopUpManager.addPopUp(winPop,this,true);
	               			PopUpManager.centerPopUp(winPop);
				}
				
				
				private	var time:Timer= new Timer(1000);
				private function timeslide(event:MouseEvent):void
				{
						
					time.addEventListener(TimerEvent.TIMER,ontimer);
					time.start();
							
				}
				
				private var looptime:Timer = new Timer(1000);
			 	private function timeloop(event:MouseEvent):void
				{
					
					looptime.addEventListener(TimerEvent.TIMER,loopslide);
					looptime.start();
				}
				
				private	var stoptime:Timer = new Timer(1000);				
				private function stoploop(event:MouseEvent):void
				{
					
					stoptime.addEventListener(TimerEvent.TIMER,stopslide);
					stoptime.start();
				}	
										
				public	var img:Image = new Image();
				private function ontimer(event:TimerEvent):void
				{
					
						
	       		 img.load("data/"+pictures[curindex].source);
	       		  if(curindex<pictures.length -1)
	          		  {
	          		  	if(pictures[curindex].lastpage == true)
	           		 	{
	           		 	time.stop();	
	           		 	}
	           		 	else
	           		 	{
	           		 		curindex++;	
	           		 	}
	          		  		
	          		  	  	
	          		  }
	        	  	
	           		   
				}
				

				 private function loopslide(event:TimerEvent):void
				{
					
	        		var img1:Image = new Image();
	        		 img1.load("data/"+pictures[curindex].source);
	       		  if(curindex<pictures.length -1)
	          		  {
	          		  	curindex++;	
	          		  	 
	          		  }
	        	 else
	           		 {
	           		 	curindex=0;
	           		 	
	           		 	
	           		 }	
				}
				 private function stopslide(event:TimerEvent):void
				{
					looptime.stop();
	        		 img.load("data/"+pictures[curindex].source);
	       		  if(curindex<pictures.length -1)
	          		  {
	          		  	curindex++;	
	          		  	 
	          		  }
	        	 else
	           		 {
	           		 	stoptime.stop();
	           		 }
	   }
				
				private function preimage(event:MouseEvent):void
				{
					 time.stop(); 
					 looptime.stop();
					 stoptime.stop();
					if(curindex != 0)
						{
							curindex--;
							
						}
						else
						{
							
							 curindex = pictures.length-1;
						}
					
				}
				
	

				private function nextimage(event:MouseEvent):void
				{
					 time.stop(); 
					 looptime.stop();
					 stoptime.stop(); 
					if(curindex < pictures.length - 1)
						{
							curindex++;
						}
						else
						{
							curindex = 0;
						}
								
					
				} 
					
		]]>
	</mx:Script>
	<mx:HTTPService id="service" url="data/slideshow.xml" 
		result="resulthandler(event)"/>
		
		<mx:VBox id="vid" horizontalAlign="center" width="400" height="400">
			<mx:Text  id="maintext" text="{pictures.getItemAt(curindex).caption}" styleName="title"/>
			<mx:Image  id="mainimg" source="{pictures.getItemAt(curindex).source}" click="popFun(event)"/>
			 
			
		</mx:VBox>
		<mx:HBox id="paginit">
		<mx:Button id="slide" click="timeslide(event)" styleName="slideshow"/>
			<mx:Button id="btnpre"  click="preimage(event)"  styleName="previousBtn"/>
			<mx:Button id="btnnext" click="nextimage(event)" styleName="nextBtn"/>
			<mx:Button id="loopsl"  label="Loop" visible="false" click="timeloop(event)" />
			<mx:Button id="stopsl"  label="stop" visible="false" click="stoploop(event)"/>
			
		</mx:HBox>
		

</mx:Application>

and my query is that when last_page=loop is occure from xml so my slidshow is ruunig mode..inshort i want a slideshow in running mode but using last_page=loop tag in xml


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 8+7 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions