# How to turn a string in XML into a clickable link

**URL:** <https://forum.kirupa.com/t/how-to-turn-a-string-in-xml-into-a-clickable-link/303970>\
**Category:** flash\
**Created:** [January 29, 2010, 8:51pm UTC](https://forum.kirupa.com/t/how-to-turn-a-string-in-xml-into-a-clickable-link/303970 "2010-01-29T20:51:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skeeterlee](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@skeeterlee](https://forum.kirupa.com/u/skeeterlee)\
**Post date:** [January 29, 2010, 8:51pm UTC](https://forum.kirupa.com/t/how-to-turn-a-string-in-xml-into-a-clickable-link/303970/1 "2010-01-29T20:51:45Z")

</div>

hello, I have JUST joined this group and I need help.  
I want to turn a XML caption into a clickable link.

Here is my XML file: Iwant to have “Visit” be clickable and go to the website listed.  
\<GALLERY COLUMNS=“4” XPOSITION=“350” YPOSITION=“199” WIDTH=“41” HEIGHT=“34” SPEED=“2”\>  
\<IMAGE FULL=“full\_images/image1.jpg” THUMB=“thumbs/thumb1.jpg” NAME=“Prospective Students” DESCRIPTION=“Description Here!”  
INFO=“Visit” LINK=“[http://www.google.com](http://www.google.com)”/\>  
\</GALLERY\>

Here is my actionscript which I got following tutorials on Republic of Code.  
Everything works, but I NEED to the INFO node into a clickable link. Can anyone help?

import fl.transitions.Tween;  
import fl.transitions.easing.\*;  
import fl.transitions.TweenEvent;  
var myXML:XML;  
var columns:Number; // how many columns for thumbnails  
var my\_x:Number; //position of the thumbnails along x-axis  
var my\_y:Number; //position of the thumbnails along y-axis  
var my\_thumb\_width:Number; //width of single thumb  
var my\_thumb\_height:Number; //height of single thumb  
var my\_total:Number; //number of thumbnails  
var my\_images:XMLList; //a reference to the list of images to retrieve the URL and title of each image  
var my\_speed:Number;  
var my\_link:String;  
var myTimer:Timer;  
var my\_loaders\_array:Array = [];  
var my\_playback\_counter:Number = 0;  
var my\_image\_slides:Sprite = new Sprite;  
var myName:TextField = new TextField();//variable to display the Name Text  
var myNameFormat:TextFormat = new TextFormat(); // controls the size and font style  
myNameFormat.font = “Arial”;  
myNameFormat.size = 30;

myName.defaultTextFormat = myNameFormat;  
myName.textColor=0x00000;  
var myDesc:TextField = new TextField();  
var myDescFormat:TextFormat=new TextFormat();  
myDescFormat.font=“Arial”;  
myDescFormat.size=20;

myDesc.defaultTextFormat = myDescFormat;  
myDesc.textColor=0x990000;  
var myInfo:TextField = new TextField();  
var myInfoFormat:TextFormat = new TextFormat();  
myInfoFormat.font = “Arial”;  
myInfoFormat.size = 12;  
myInfoFormat.align = TextFormatAlign.RIGHT; //aligns right to the TextField width (myURL.width)  
myInfo.defaultTextFormat = myInfoFormat;  
myInfo.textColor = 0x000000;  
var container\_mc:MovieClip; //variable to display the thumbnails  
var myXMLLoader:URLLoader = new URLLoader();  
myXMLLoader.load(new URLRequest(“GALLERY\_NEW.xml”)); //loads the XML file  
myXMLLoader.addEventListener(Event.COMPLETE, processXML); //this listens for the Event.COMPLETE which we called processXML.

function processXML(e:Event):void //processing the XML via this function. The code to be triggered must be in this function.  
{  
var myXML:XML = new XML(e.target.data); // creating an instance of XML Class & assigning the data to the XML file  
columns = [myXML.@COLUMNS](mailto:myXML.@COLUMNS);  
my\_x = [myXML.@XPOSITION](mailto:myXML.@XPOSITION);  
my\_y = [myXML.@YPOSITION](mailto:myXML.@YPOSITION);  
my\_thumb\_width = [myXML.@WIDTH](mailto:myXML.@WIDTH);  
my\_thumb\_height = [myXML.@HEIGHT](mailto:myXML.@HEIGHT);  
my\_images = myXML.IMAGE; //assigning thumbnail tag in XML file to variable thumbimages  
my\_total = my\_images.length(); //refers to the total number of thumbnails in XML file  
my\_speed = [myXML.@SPEED](mailto:myXML.@SPEED);  
my\_link = [myXML.@LINK](mailto:myXML.@LINK);  
/\* these functions are automatically called on upload \*/  
createContainer();//this function gets called with the processXML() function is called  
callThumbs(); //call the function callThumbs on upload  
callFull(null);//call the function CallFull on upload  
}  
function createContainer():void //this function is making a container to display the thumbnails  
{  
container\_mc = new MovieClip();  
container\_mc.x = my\_x; //position the thumbnails on the x-axis using my\_x  
container\_mc.y = my\_y; //positons the thumbnails on the y-axis using my\_y  
addChild(container\_mc); //adding MovieClip to display list  
/_registering mouse click to the thumbnails. register the event listerner to the container\_mc, eliminates repeating for every thumbnail._/  
container\_mc.addEventListener(MouseEvent.CLICK, callFull);

container\_mc.buttonMode = true; //activates the Finger Cursor for the thumbnails

/_add hover effect back after taking it away_ call in the function onOver\*/  
container\_mc.addEventListener(MouseEvent.MOUSE\_OVER, onOver);  
container\_mc.addEventListener(MouseEvent.MOUSE\_OUT, onOut);  
}

//function = call Thumbs, load the thumbnails; you need the Loader Class to load images  
function callThumbs():void  
{  
for (var i:Number = 0; i \< my\_total; i++) //thumbtotal = total of thumbnails  
{  
var thumb\_url = my\_images\*.@THUMB; //i cycles thru the XML elements & retrieves URL by using @ operator  
//thumbimages = thumbnail in XML file; storing the URL of thumbnails in local variable thumb\_url  
var thumb\_loader = new Loader();  
// create new temporary instance of Loader Class using “new” and then instantly load the thumb image using .load()  
thumb\_loader.load(new URLRequest(thumb\_url));  
thumb\_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded); //show thumbnails when loaded, register the Event.COMPLETE, by using .addEventListerner, special listerner = thumbloaded  
thumb\_loader.x = (my\_thumb\_width+10)_i; //the width of each thumbnail = my\_thumb\_width so multiply by “i” my\_thumb\_width_i to get the thumbnails side by side. To get space (my\_thumb\_width+10)\*i  
thumb\_loader.name = i; //this saves the name of each thumbnail

myName.text = my\_images[0].@NAME;  
myDesc.text = my\_images[0].@DESCRIPTION; myInfo.text = my\_images[0].@INFO;  
}

}

function thumbLoaded(e:Event):void  
{  
var my\_thumb:Loader = Loader(e.target.loader);  
container\_mc.addChild(my\_thumb);  
}

/_adds a hover to the thumbnails_/  
function onOver (e:MouseEvent):void  
{  
var my\_thumb:Loader = Loader(e.target);  
my\_thumb.alpha = 0.4; //fades 60%  
}  
function onOut (e:MouseEvent):void  
{  
var my\_thumb:Loader = Loader (e.target);  
my\_thumb.alpha = 1;  
}  
/_adds the item 1 text as default on upload_/  
// calling the full images  
function callFull(e:MouseEvent):void  
{

var full\_loader:Loader = new Loader(); //full\_loader references the full Image  
var full\_url;

if (e != null)  
{  
full\_url = my\_images[e.target.name].@FULL;  
myName.text = my\_images[e.target.name].@NAME;  
myDesc.text = my\_images[e.target.name].@DESCRIPTION;  
myInfo.text = my\_images[e.target.name].@INFO;  
}  
else  
{  
full\_url = my\_images[0].@FULL;

}

full\_loader.load(new URLRequest(full\_url));  
full\_loader.contentLoaderInfo.addEventListener(Event.INIT, fullLoaded);  
}  
function fullLoaded(e:Event):void  
{

var my\_loader:Loader = Loader(e.target.loader);  
addChild(my\_loader);  
my\_loader.x=7;  
my\_loader.y=2;  
new Tween(my\_loader,“alpha”,Strong.easeOut,0,1,1,true);

addChild(myName);  
myName.x=5;  
myName.y=200;  
myName.width=300;

addChild(myDesc); //calls the DESCRIPTION attribute  
myDesc.x=5;  
myDesc.y=245;  
myDesc.width=566;  
myDesc.height=100;  
myDesc.wordWrap=true;

addChild(myInfo);  
myInfo.x = 5;  
myInfo.y = 289;  
myInfo.width = 548; //width of the myURL TextField  
}
