A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Carousel help

  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Angry Carousel help

    Hi,

    I downloaded this carousel http://pv3d.org/2008/12/01/carousel-...ion/index.htmland am trying to modify it to suit my needs, but I would like to get it out of Flash Builder and into Flash as I'm really having trouble with the images and need some sort of visualization. Does anyone know how to do this?

    I've been using another carousel(came from here: http://www.webspaceinvader.com/2007/...sel-interface/ and I'm attaching the .as which is mostly finished in Flash. Unfortunately, it has some weird motion on the z-axis when you click on it, which I do not want. Perhaps, someone knows how to fix that and then I wouldnt have to worry about the first issue.

    Thanks,
    ---Yvette
    Attached Files Attached Files

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I created special AS3 classes for the carousel. Can be downloaded here and are documented

    http://flashscript.biz/flashas3/biz/FS_biz_classes.html
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Thanks cancerinform

    I tried your sample, but I couldn't get it to work---For the CarousselOne.fla are you supposed to link it to the AS file(Carousselone.as)through its main document class path?
    I don't think it would help me anyway as I need a very specialized carousel...Basically, it needs to display 15 images(in the foreground on the main circular arc--don't really need any images in the background(beyond 180 degrees on the circle)) with no space between them(they would be in a container which has a graphic for their sides)and I don't want them to automatically rotate..just rotate on a click event--also, I would need some type of tooltip or just a textfield filled with the image title on the MOUSE_OVER event and for a DOUBLE_CLICK event I would want to display information about the images, in a separate MC textfield...

    I'm guess your class modifies the carousel I had linked to first(the pv3d.org one)...I actually nearly finished two other carousels( http://www.webspaceinvader.com/2007/...sel-interface/) and the one lee brimelow created---The webspaceinvader one is almost completely coded--the only problem is that rotation in z-space on click as I need my images to stay in the same z-plane, which I don't really understand and have been unable to fix...Actually, it has an on enterframe loop which constantly updates the view and it also has a moveBackward call which would need to be fixed:
    Code:
    private function update3D():void
    		{
    			var target:DisplayObject3D = camera.target;
    			var goPosition:DisplayObject3D = camera.extra.goPosition;
    			var goTarget:DisplayObject3D = camera.extra.goTarget;
    
    			camera.x -= (camera.x - goPosition.x) /12;
    			camera.y -= (camera.y - goPosition.y) /12;
    			camera.z -= (camera.z - goPosition.z) /12;
    
    			target.x -= (target.x - goTarget.x) /12;
    			target.y -= (target.y - goTarget.y) /12;
    			target.z -= (target.z - goTarget.z) /12;
    if all the coordinates are divided by 1 instead of 12 it more suits my needs(that is, it doesn't come forward in z-space), however it no longer performs any type of visible rotation--just jumps to the image, I have no clue as to how to fix it.

    The one I am currently using is the one Lee Brimelow created--I have it all modified, but am stuck with one problem--working with the XML---
    Code:
    package 
    {
    	import com.gskinner.motion.GTween;
    	import com.leebrimelow.utils.Math2;
    	import com.theflashblog.fp10.SimpleZSorter;
    
    	import fl.motion.easing.Exponential;
    
    	import flash.display.*;
    	import flash.events.Event;
    	import flash.events.MouseEvent;
    	import flash.net.URLLoader;
    	import flash.net.URLRequest;
    
    	public class Carousel extends Sprite
    	{
    		private var container:Sprite;
    		private var loader:URLLoader;
    		private var anglePer:Number;
    		private var mytooltip:MovieClip = new tooltip  ;
    
    		public function Carousel()
    		{
    			init();
    			loadXML();
    		}
    
    		private function loadXML():void
    		{
    			loader = new URLLoader(new URLRequest("images.xml"));
    			loader.addEventListener(Event.COMPLETE, createCarousel);
    		}
    
    		private function createCarousel(e:Event):void
    		{
    			var xml:XML = new XML(e.target.data);
    			var list:XMLList = xml.image;
    			anglePer = (Math.PI*2) / list.length();
    
    			for (var i:int=0; i<list.length(); i++)
    			{
    				var mytooltip= new tooltip;
    				var imc:imCon = new imCon();
    				imc.buttonMode = true;
    				imc.alpha = .8;
    				imc.addEventListener(MouseEvent.CLICK, onClick);
    				imc.addEventListener(MouseEvent.MOUSE_OVER, onMOver);
    				imc.addEventListener(MouseEvent.MOUSE_OUT, onMOut);
    				imc.mouseChildren = false;
    				imc.doubleClickEnabled = true;
    				imc.addEventListener(MouseEvent.DOUBLE_CLICK, onDouble);
    				var l:Loader = new Loader();
    				l.x = -126;
    				l.y = -94;
    				l.load(new URLRequest(list[i].@src));
    	
    				//var et:DisplayObject = l.content as MovieClip;
    				var toolText:String;
    				toolText = list[i]. @ tooltip;
    				if(toolText !=""){
    				mytooltip.tipText.text=toolText;
    				}
    				
    				
    				var info:String;
    				info = list[i]. @ content;
    				//trace(toolText,"tt");
    				imc.addChild(l);
    				imc.scaleX = .4;
    				imc.scaleY = .5;
    				imc.angle = (i * anglePer) - Math.PI / 2;
    				if (i>8 && i<37)
    				{
    					
    				}
    				imc.x = Math.cos(imc.angle) * 550;
    				imc.z = Math.sin(imc.angle) * 550;
    				imc.rotationY = 360 / list.length() *  -  i;
    				container.addChild(imc);
    				mytooltip.x = imc.x-imc.width/2;
    				mytooltip.y = imc.y - 100;
    				mytooltip.alpha=0;
    				imc.addChild(mytooltip);
    				
    				//et.addChild(mytooltip);
    				
    			}
    		}
    
    		private function onClick(e:MouseEvent):void
    		{
    			//var et:DisplayObject = e.currentTarget as DisplayObject;
    			trace(e.currentTarget.name);
    			//e.currentTarget.alpha=1;
    			var tw:GTween = new GTween(container, 0.8, {rotationY:Math2.toDeg(e.currentTarget.angle+Math.PI/2), z:400},
    			{ease:Exponential.easeInOut});
    		}
    
    		private function onDouble(e:MouseEvent):void
    		{
    
    			trace("clicked twice");
    
    		}
    
    		private function onMOver(e:MouseEvent):void
    		{
    			//trace(e.currentTarget);
    			//mytooltip.tipText.text=e.currentTarget.et. @ tooltip;
    			/*mytooltip.x = e.currentTarget.mouseX;
    			mytooltip.y = e.currentTarget.mouseY - 25*/
    			//e.currentTarget.addChild(mytooltip);
    			moveTip();
    			e.currentTarget.mytooltip.alpha=1;//this throws an error as I can't seem to target the imc's child 
    
    			e.currentTarget.alpha = 1;
    
    		}
    		private function onMOut(e:MouseEvent):void
    		{
    
    			e.currentTarget.alpha = .8;
    
    		}
    		function moveTip()
    		{
    			/*mytooltip.x = mouseX;
    			mytooltip.y = mouseY-20;*/
    		}
    
    
    		private function init():void
    		{
    			container = new Sprite();
    			container.x = 450;
    			container.y = 145;
    			container.z = 400;
    			addChild(container);
    
    			//cover.addEventListener(MouseEvent.CLICK, stageClick);
    			this.addEventListener(Event.ENTER_FRAME, loop);
    		}
    
    		/*private function stageClick(e:MouseEvent):void
    		{
    		var tw:GTween = new GTween(container, 0.8, {z:400}, {ease:Exponential.easeInOut});
    		}*/
    
    		private function loop(e:Event):void
    		{
    
    			SimpleZSorter.sortClips(container);
    		}
    	}
    }
    The tooltip(mc in library with a textfield) attaches ok(as can be shown if you leave their alpha=1 in the createCarousel function) , but accessing that tooltip(which I add as a child of the imc) I cant figure out how to do...I also don't know how to return the name of the clip on the doubleclick event--I just get an instance, so I wouldnt be able to display the content(desc)XML node...
    Do I need to set up an array? Or how do I go about referencing the imc children?

    Thanks so much,
    ---Yvette
    Last edited by yvillicana; 11-21-2012 at 01:11 PM.

  4. #4
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Got it

    Hi and thanks cancerinform,

    Think I have it solved---I made some arrays and am storing the XML elements in them--seems to be working out...Thanks for your help

    ---Yvette

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center