Here is the scenario… I am attempting to create a carousel image gallery each image is accompanied by a url that when pressed will take the viewer to an external website.
I am pulling this information from an xml document “images.xml”
I am using a dynamic textfield with an instance name “links” to hold the urls.
The problem is the URLs are not changing when I selected a new image…
How can I make it so that when a user clicks on image1 for example they’ll get “View Google” and when they click on image2 they’ll get “View YouTube” etc?
Any Suggestions and Comments are welcome!
Here is my XML:
<?xml version=“1.0” encoding=“UTF-8”?>
<images>
<image src=“img/Layer-1.png” />
<urltxt><a href=“http://www.google.com”>Cops</a></urltxt>
<image src=“img/Layer-2.png” />
<urltxt><a href=“http://www.google.com”>Dogs</a></urltxt>
<image src=“img/Layer-3.png” />
<urltxt><a href=“http://www.google.com”>Rabbits</a></urltxt>
<image src=“img/Layer-4.png” />
<urltxt><a href=“http://www.google.com”>LINK TO GOOGLE</a></urltxt>
<image src=“img/Layer-5.png” />
<urltxt><a href=“http://www.google.com”>LINK TO GOOGLE</a></urltxt>
<image src=“img/Layer-6.png” />
<urltxt><a href=“http://www.google.com”>LINK TO GOOGLE</a></urltxt>
<image src=“img/Layer-7.png” />
<urltxt><a href=“http://www.google.com”>LINK TO GOOGLE</a></urltxt>
<image src=“img/Layer-8.png” />
<urltxt><a href=“http://www.google.com”>LINK TO GOOGLE</a></urltxt>
<image src=“img/Layer-9.png” />
<urltxt><a href=“http://www.google.com”>LINK TO GOOGLE</a></urltxt>
<image src=“img/Layer-10.png” />
<urltxt><a href=“http://www.google.com”>LINK TO GOOGLE</a></urltxt>
</images>
Here is the class I am using:
package {
import com.gskinner.motion.GTween;
import com.leebrimelow.utils.Math2;
import com.theflashblog.fp10.SimpleZSorter;
import fl.motion.easing.Exponential;
import flash.display.Loader;
import flash.display.Sprite;
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 loader2:URLLoader;
private var xmlLoader:URLLoader;
private var anglePer:Number;
private var arrayLister:Number;
public function Carousel() {
init();
loadXML();
myXML();
}
private function loadXML():void {
loader=new URLLoader(new URLRequest("images.xml"));
loader.addEventListener(Event.COMPLETE, createCarousel);
}
private function myXML():void {
loader2=new URLLoader(new URLRequest("images.xml"));
loader2.addEventListener(Event.COMPLETE, createLinks);
}
private function createLinks(e:Event):void {
var myXML=new XML(e.target.data);
arrayLister=myXML.length();
for (var i:int=0; i<myXML.length(); i++) {
links.htmlText=myXML.urltxt;
// links.pop();
}
}
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 imc:imCon = new imCon();
imc.buttonMode=true;
imc.addEventListener(MouseEvent.CLICK, onClick);
var l:Loader = new Loader();
l.x=-250;
l.y=-167;
l.load(new URLRequest(list*.@src));
imc.addChild(l);
imc.scaleX=imc.scaleY=0.5;
imc.angle = (i*anglePer) - Math.PI/ 2;
imc.x=Math.cos(imc.angle)*450;
imc.z=Math.sin(imc.angle)*450;
imc.rotationY=36*- i;
container.addChild(imc);
}
}
private function onClick(e:MouseEvent):void {
var tw:GTween = new GTween(container,0.8, {rotationY:Math2.toDeg(e.currentTarget.angle+Math. PI/2), z:100},
{ease: Exponential.easeInOut});
}
private function init():void {
container=new Sprite ;
container.x=350;
container.y=250;
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.eas eInOut});
}
private function loop(e:Event):void {
SimpleZSorter.sortClips(container);
}
}
}