A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Carouhell

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

    Angry Carouhell

    Hi,

    This is another carousel I've been working with--lee brimelow's http://gotoandlearn.com/play.php?id=92, which loads in the images through XML. I amended the XML to contain a tooltip element which would hold the tooltip text which should be displayed on MOUSE_OVER and a desc element which should be displayed in another mc on DOUBLE_CLICK. The problem is I can't seem to get the tooltip to display on the MOUSE_OVER event and they also dont line up correctly. I'm able to see the tooltips if I leave their alpha=1, but I can't see to access the tooltip clip in the MOUSE_OVER function.
    Here is the full code:
    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;
    			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);
    		}
    	}
    }
    and the XML file looks like this:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <images>
    	<image src="img/portfolio_new1.png" tooltip="Yahoo Messenger for Vista" content="LimeWire is a peer-to-peer file sharing client for the Gnutella network. It is free software released under the GNU General Public License. Limewire was the first file sharing program to support firewall-to-firewall file transfers, a feature introduced in version 4.2, which was released in November 2004.LimeWire is written in Java and therefore runs on any computer with a Java Virtual Machine installed. To facilitate installation for casual users, installation packages are available for Microsoft Windows, Mac OS X, and in the RPM format for Linux. Support for Mac OS 9 and previous versions has been dropped with LimeWire 4.0.10. The Windows version of the LimeWire installer includes a version of Sun Microsystems' Java installer which will download and install version 1.5 of the Java Runtime Environment if it detects the machine does not have a recent version of Java installed."  />
    	<image src="img/portfolio_new2.png" tooltip="IBM presentation" />
    	<image src="img/portfolio_new3.png" />
    	<image src="img/portfolio_new4.png" />
    	<image src="img/portfolio_new5.png" />
    	<image src="img/portfolio_new6.png" />
    	<image src="img/portfolio_new7.png" />
    	<image src="img/portfolio_new8.png" />
    	<image src="img/portfolio_new9.png" />
    	<image src="img/portfolio_new10.png" />
    	<image src="img/portfolio_new1.png" />
    	<image src="img/portfolio_new2.png" />
    	<image src="img/portfolio_new3.png" />
    	<image src="img/portfolio_new4.png" />
    	<image src="img/portfolio_new5.png" />
    	<image src="img/portfolio_new6.png" />
    	<image src="img/portfolio_new7.png" />
    	<image src="img/portfolio_new8.png" />
    	<image src="img/portfolio_new9.png" />
    	<image src="img/portfolio_new10.png" />
    	<image src="img/portfolio_new1.png" />
    	<image src="img/portfolio_new2.png" />
    	<image src="img/portfolio_new3.png" />
    	<image src="img/portfolio_new4.png" />
    	<image src="img/portfolio_new5.png" />
    	<image src="img/portfolio_new6.png" />
    	<image src="img/portfolio_new7.png" />
    	<image src="img/portfolio_new8.png" />
    	<image src="img/portfolio_new9.png" />
    	<image src="img/portfolio_new10.png" />
    	<image src="img/portfolio_new1.png" />
    	<image src="img/portfolio_new2.png" />
    	<image src="img/portfolio_new3.png" />
    	<image src="img/portfolio_new4.png" />
    	<image src="img/portfolio_new5.png" />
    	<image src="img/portfolio_new6.png" />
    	<image src="img/portfolio_new7.png" />
    	<image src="img/portfolio_new8.png" />
    	<image src="img/portfolio_new9.png" />
    	<image src="img/portfolio_new10.png" />
    	<image src="img/portfolio_new1.png" />
    	<image src="img/portfolio_new2.png" />
    	<image src="img/portfolio_new3.png" />
    	<image src="img/portfolio_new4.png" />
    </images>
    Can someone please help me with accessing the moused over image's tooltip? and possibly direct me how to do this with the desc(content)XML element?


    Thanks,
    ---Yvette

  2. #2
    Senior Member
    Join Date
    Oct 2005
    Posts
    198
    Got it--used arrays to store the XML

    Thanks

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