|
-
Can't Get This To Work *SIGH* Please help!
I completed the Click and Zoom 3D Carousel tutorial by Lee from gotoandlearn.com. What I am now trying to do is add links to external websites for each photo when zoomed. In hopes of accomplishing this task I have created a dynamic textfield with an instance name of "links" on the stage area.
In the Carousel class I have added the following code :
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);
var xmllist:XMLList=myXML.urltxt;
arrayLister=xmllist.length();
links.htmlText = xmllist;
}
and the following in images.xml :
<?xml version="1.0" encoding="UTF-8"?>
<images>
<image src="img/Layer-1.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-2.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-3.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-4.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-5.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-6.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-7.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-8.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-9.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
<image src="img/Layer-10.png" />
<urltxt><![CDATA[ <a href="http://www.google.com">LINK TO GOOGLE</a> ]]></urltxt>
</images>
The problem is the URL(s) are not visible in my dynamic textfield "links", however the dummy text I placed in links disappears at runtime.
PLEASE HELP!!!!
-
Senior Member
I don't understand why people (you are not the only one) are using the CDATA section to show text in Flash. Text within CDATA is not parsed. This is a node of the corrected xml
PHP Code:
<urltxt><a href="http://www.google.com">LINK TO GOOGLE</a></urltxt>
- The right of the People to create Flash movies shall not be infringed. -
-
Thanks! I changed my xml file, unfortunately I am still unable to see the URLs in my dynamic textfield "links".
Any Ideas?
-
Senior Member
Worked for me, although I did not use your script. Don't make it XMLList. Just use myXML directly or write
links.htmlText=myXML.urltxt;
- The right of the People to create Flash movies shall not be infringed. -
-
I was doing two things wrong.. you were correct I didn't need XMLList and my textfield was too small.
The URLs aren't changing when I select a picture and I would like for each picture to have its own URL. Could I accomplish this by either .push or .pop ?
Maybe something like:
for (var i:int=0; i<myXML.urltxt.length(); i++) {
LinkList.push(myXML.urltxt[i]);
links.htmlText=LinkList;
}
???
-
Senior Member
Just do as in html:
<urltxt><a href="http://www.google.com"><img src="img/Layer-1.png"/></a></urltxt>
<urltxt><a href="http://www.flashscript.biz"><img src="img/Layer-2.png"/></a></urltxt>
etc
- The right of the People to create Flash movies shall not be infringed. -
-
When I use that xml format I am unable to see the gallery photos as well as the links. Here is the class in entirety:
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[i].@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);
}
}
}
-
CancerInForm Thanks again for your help. I'm still working on making this thing work...
This is where I am having problems ( I don't know how highlight the script I apologize)
<script>
private function createCarousel(e:Event):void {
var xml:XML=new XML(e.target.data);
//var list:XMLList=xml.image;
anglePer=Math.PI*2/xml.image.urlimage.length();
for (var i:int=0; i<xml.image.urlimage.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(xml.image.urlimage[i]));
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);
for (var k:int=0; k<xml.image.link.length(); k++) {
links.htmlText =xml.image.link;
}
}
}
</script>
Here is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<images>
<image>
<urlimage>img/Layer-1.png</urlimage>
<link><a href="http://www.adobe.com">Cops</a></link>
</image>
<image>
<urlimage>img/Layer-2.png</urlimage>
<link><a href="http://www.adobe.com">Robo</a></link>
</image>
<image>
<urlimage>img/Layer-3.png</urlimage>
<link><a href="http://www.adobe.com">Rabbit</a></link>
</image>
<image>
<urlimage>img/Layer-4.png</urlimage>
<link><a href="http://www.adobe.com">Bee</a></link>
</image>
<image>
<urlimage>img/Layer-5.png</urlimage>
<link><a href="http://www.adobe.com">Five</a></link>
</image>
<image>
<urlimage>img/Layer-6.png</urlimage>
<link><a href="http://www.adobe.com">Sixo</a></link>
</image>
<image>
<urlimage>img/Layer-7.png</urlimage>
<link><a href="http://www.adobe.com">Heavan</a></link>
</image>
<image>
<urlimage>img/Layer-8.png</urlimage>
<link><a href="http://www.adobe.com">Cape</a></link>
</image>
<image>
<urlimage>img/Layer-9.png</urlimage>
<link><a href="http://www.adobe.com">Time</a></link>
</image>
<image>
<urlimage>img/Layer-10.png</urlimage>
<link><a href="http://www.adobe.com">Ribs</a></link>
</image>
</images>
As a re-cap I am trying to load the node <link> which contains a url to an external website in a dynamic text field with an instance name "links" ... but I want the node <link> to correspond with its imagine when the user. For example when when "image-9.png" is selected I want the links to say "TIME". Currently I am getting all the images but links is stuff on "RIBS" which is the correspond of the last node / child ....
When I put " links.htmlText += xml.image.urlimage[i].link.text();
either nothing appears in links or it is populated with "<urlimage>img/Layer-1.png</urlimage> Cops ... "
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|