# XML - Am I screwed?

**URL:** <https://forum.kirupa.com/t/xml-am-i-screwed/299369>\
**Category:** flash\
**Created:** [November 4, 2009, 12:40am UTC](https://forum.kirupa.com/t/xml-am-i-screwed/299369 "2009-11-04T00:40:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steamin](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/steamin/32/1291_2.png) [@steamin](https://forum.kirupa.com/u/steamin)\
**Post date:** [November 4, 2009, 12:40am UTC](https://forum.kirupa.com/t/xml-am-i-screwed/299369/1 "2009-11-04T00:40:06Z")

</div>

I think I might be unless someone brilliant can help.  
I’m working with a flash template that loads external images and text using an xml file.  
Everything works well the only problem is I’ve promised a client that as well as a “title” and “description” I will also include a clickable URL link. I can edit the flash to a certain extent but I am having a nightmare of a time including a clickable url. Is there anyone out there who can help?

“photo\_description”, “photo\_title” and “photo\_url” are the names of the dynamic text fields.  
Here is the AS…

// Copyright © [flashmo.com](http://flashmo.com)  
// Developed by Min Thu  
// Tweener  
// [http://code.google.com/p/tweener/](http://code.google.com/p/tweener/)  
import caurina.transitions._;  
var folder:String = “photos/”;  
var follow\_mouse:Boolean = true; // true OR false  
var tween\_duration:Number = 0.5;  
var default\_tn\_scale:Number = 0.8;  
var default\_pic\_alpha:Number = 0.25;  
var new\_scale:Number;  
var tn\_border:Number = 5;  
var speed:Number = 12; // from 1 to 20  
var i:Number;  
var j:Number;  
var tn:Number = 0;  
var tn\_distance:Number;  
var current\_no:Number = 0;  
var total:Number;  
var flashmo\_xml:XML;  
var flashmo\_photo\_list = new Array();  
var current\_mc:MovieClip = new MovieClip();  
var flashmo\_pic:MovieClip = new MovieClip();  
var thumbnail\_group:MovieClip = new MovieClip();  
this.addChild(flashmo\_pic);  
this.addChild(thumbnail\_group);  
this.addChild(flashmo\_text\_info);  
flashmo\_pic.alpha = default\_pic\_alpha;  
flashmo\_pic.x = flashmo\_photo\_area.x;  
flashmo\_pic.y = flashmo\_photo\_area.y;  
flashmo\_pic.mask = flashmo\_photo\_area;  
thumbnail\_group.x = 100;  
thumbnail\_group.y = flashmo\_thumbnail\_area.y;  
thumbnail\_group.mask = flashmo\_thumbnail\_area;  
loading\_info.text = “”;  
thumbnail\_info.text = “”;  
flashmo\_photo\_title.text = “”;  
flashmo\_text\_info.alpha = 0;  
flashmo\_text\_info.photo\_title.text = “”;  
flashmo\_text\_info.photo\_description.text = “”;  
if( Math.abs(speed) \> 20 ) speed = 10;  
speed = Math.abs(speed);  
function load\_gallery(xml\_file:String):void  
{  
var xml\_loader:URLLoader = new URLLoader();  
xml\_loader.load( new URLRequest( xml\_file ) );  
xml\_loader.addEventListener(Event.COMPLETE, create\_thumbnail);  
}  
function create\_thumbnail(e:Event):void  
{  
flashmo\_xml = new XML(e.target.data);  
total = flashmo\_xml.photo.length();  
for( i = 0; i \< total; i++ )  
{  
flashmo\_photo\_list.push( {  
thumbnail: flashmo\_xml.photo_.thumbnail.toString(),  
filename: flashmo\_xml.photo\*.filename.toString(),  
title: flashmo\_xml.photo\*.title.toString(),  
description: flashmo\_xml.photo\*.description.toString()  
} );  
}  
load\_photo();  
load\_tn();  
}  
function load\_photo():void  
{  
var pic\_request:URLRequest = new URLRequest( folder + flashmo\_photo\_list[current\_no].filename );  
var pic\_loader:Loader = new Loader();  
pic\_loader.load(pic\_request);  
pic\_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, on\_photo\_progress);  
pic\_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,on\_photo\_loaded);

flashmo\_text\_info.photo\_title.text = flashmo\_photo\_list[current\_no].title;  
flashmo\_text\_info.photo\_description.text = flashmo\_photo\_list[current\_no].description;  
flashmo\_pic.alpha = 0;  
}  
function unload\_photo():void  
{  
flashmo\_pic.removeChildAt(0);  
load\_photo();  
}  
function on\_photo\_progress(e:ProgressEvent):void  
{  
var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal \* 100);  
loading\_info.text = "Loading Image… " + percent + “%”;  
}  
function on\_photo\_loaded(e:Event):void  
{  
loading\_info.text = “”;  
flashmo\_pic.addChild( Bitmap(e.target.content) );  
flashmo\_pic.addEventListener( MouseEvent.MOUSE\_OVER, pic\_over );  
flashmo\_pic.addEventListener( MouseEvent.MOUSE\_OUT, pic\_out );  
Tweener.addTween( flashmo\_pic, { alpha: default\_pic\_alpha, time: tween\_duration, transition: “easeOutQuart” } );  
thumbnail\_group.addEventListener( MouseEvent.MOUSE\_OVER, pic\_over );  
}  
function load\_tn():void  
{  
var pic\_request:URLRequest = new URLRequest( folder + flashmo\_photo\_list[tn].thumbnail );  
var pic\_loader:Loader = new Loader();  
pic\_loader.load(pic\_request);  
pic\_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on\_thumbnail\_loaded);  
tn++;  
thumbnail\_info.text = "Loading Thumbnail " + tn + " of " + total;

if( tn == 8 )  
thumbnail\_group.addEventListener( Event.ENTER\_FRAME, fisheye\_thumbnails );  
}  
function on\_thumbnail\_loaded(e:Event):void  
{  
var flashmo\_tn\_bm:Bitmap = new Bitmap();  
var flashmo\_tn\_mc:MovieClip = new MovieClip();  
flashmo\_tn\_bm = Bitmap(e.target.content);  
flashmo\_tn\_bm.x = - flashmo\_tn\_bm.width \* 0.5;  
flashmo\_tn\_bm.y = - flashmo\_tn\_bm.height;  
flashmo\_tn\_bm.smoothing = true;

var bg\_width:Number = flashmo\_tn\_bm.width + tn\_border \* 2;  
var bg\_height:Number = flashmo\_tn\_bm.height + tn\_border \* 2;  
flashmo\_tn\_mc.graphics.beginFill(0xFFFFFF);  
flashmo\_tn\_mc.graphics.drawRect( - bg\_width \* 0.5, - bg\_height + tn\_border, bg\_width, bg\_height );  
flashmo\_tn\_mc.graphics.endFill();  
flashmo\_tn\_mc.addChild(flashmo\_tn\_bm);

flashmo\_tn\_mc.buttonMode = true;  
flashmo\_tn\_mc.addEventListener( MouseEvent.MOUSE\_OVER, tn\_over );  
flashmo\_tn\_mc.addEventListener( MouseEvent.MOUSE\_OUT, tn\_out );  
flashmo\_tn\_mc.addEventListener( MouseEvent.CLICK, tn\_click );

flashmo\_tn\_mc.name = “flashmo\_” + thumbnail\_group.numChildren;  
flashmo\_tn\_mc.x = thumbnail\_group.numChildren \* 80;  
flashmo\_tn\_mc.y = 110;  
flashmo\_tn\_mc.scaleX = flashmo\_tn\_mc.scaleY = default\_tn\_scale;  
thumbnail\_group.addChild(flashmo\_tn\_mc);

if( tn \< total )  
load\_tn();  
else  
thumbnail\_info.text = “”;  
}  
function tn\_over(e:MouseEvent):void  
{  
var mc:MovieClip = MovieClip(e.target);  
var s\_no:Number = parseInt(mc.name.slice(8,10));

if( s\_no \> 1 )  
thumbnail\_group.addChild( thumbnail\_group.getChildByName(“flashmo\_” + (s\_no-2) ) );  
if( s\_no \> 0 )  
thumbnail\_group.addChild( thumbnail\_group.getChildByName(“flashmo\_” + (s\_no-1) ) );  
if( s\_no \< thumbnail\_group.numChildren - 2 )  
thumbnail\_group.addChild( thumbnail\_group.getChildByName(“flashmo\_” + (s\_no+2) ) );  
if( s\_no \< thumbnail\_group.numChildren - 1 )  
thumbnail\_group.addChild( thumbnail\_group.getChildByName(“flashmo\_” + (s\_no+1) ) );

thumbnail\_group.addChild(mc);  
flashmo\_photo\_title.text = flashmo\_photo\_list[s\_no].title;  
}  
function tn\_out(e:MouseEvent):void  
{  
var mc:MovieClip = MovieClip(e.target);  
thumbnail\_group.addChild(mc);  
flashmo\_photo\_title.text = “”;  
}  
function tn\_click(e:MouseEvent):void  
{  
var mc:MovieClip = MovieClip(e.target);  
current\_no = parseInt(mc.name.slice(8,10));  
Tweener.addTween( flashmo\_pic, { alpha: 0, time: tween\_duration,  
transition: “easeInQuart”, onComplete: unload\_photo } );  
flashmo\_pic.removeEventListener( MouseEvent.MOUSE\_OVER, pic\_over );  
flashmo\_pic.removeEventListener( MouseEvent.MOUSE\_OUT, pic\_out );  
thumbnail\_group.removeEventListener( MouseEvent.MOUSE\_OVER, pic\_over );  
}  
flashmo\_text\_info.addEventListener( MouseEvent.MOUSE\_OVER, info\_over );  
flashmo\_text\_info.addEventListener( MouseEvent.MOUSE\_OUT, info\_out );  
function pic\_over(e:MouseEvent):void  
{  
Tweener.addTween( flashmo\_pic, { alpha: default\_pic\_alpha, time: tween\_duration, transition: “easeIn” } );  
Tweener.addTween( thumbnail\_group, { alpha: 1, time: tween\_duration, transition: “easeOut” } );  
}  
function pic\_out(e:MouseEvent):void  
{  
Tweener.addTween( flashmo\_pic, { alpha: 1, time: tween\_duration, transition: “easeOut” } );  
Tweener.addTween( thumbnail\_group, { alpha: 0, time: tween\_duration, transition: “easeIn” } );  
}  
function info\_over(e:MouseEvent):void  
{  
Tweener.addTween( flashmo\_pic, { alpha: 1, time: tween\_duration, transition: “easeOut” } );  
Tweener.addTween( thumbnail\_group, { alpha: 0, time: tween\_duration, transition: “easeIn” } );  
Tweener.addTween( flashmo\_text\_info, { alpha: 1, time: tween\_duration, transition: “easeIn” } );  
}  
function info\_out(e:MouseEvent):void  
{  
Tweener.addTween( flashmo\_text\_info, { alpha: 0, time: tween\_duration, transition: “easeOut” } );  
}  
function fisheye\_thumbnails(e:Event):void  
{  
thumbnail\_group.x -= ( mouseX - flashmo\_thumbnail\_area.width \* 0.5 ) \* 0.005 \* speed;

if( thumbnail\_group.x \> flashmo\_thumbnail\_area.x + 100 )  
{  
thumbnail\_group.x = flashmo\_thumbnail\_area.x + 100;  
}  
else if( thumbnail\_group.x \< flashmo\_thumbnail\_area.x - thumbnail\_group.width + flashmo\_thumbnail\_area.width )  
{  
thumbnail\_group.x = flashmo\_thumbnail\_area.x - thumbnail\_group.width + flashmo\_thumbnail\_area.width;  
}

if( mouseY \> flashmo\_thumbnail\_area.y && mouseY \< flashmo\_thumbnail\_area.y + flashmo\_thumbnail\_area.height )  
{  
for( j = 0; j \< thumbnail\_group.numChildren; j++ )  
{  
current\_mc = MovieClip(thumbnail\_group.getChildAt(j));  
tn\_distance = Math.sqrt(  
Math.pow( Math.abs( mouseX - (current\_mc.x + thumbnail\_group.x) ) , 2)

- Math.pow( Math.abs( mouseY - (current\_mc.y + thumbnail\_group.y) ) , 2)  
);  
new\_scale = 1.1 - ( tn\_distance \* 0.002 );  
current\_mc.scaleX += (new\_scale - current\_mc.scaleX) \* 0.2;  
current\_mc.scaleY += (new\_scale - current\_mc.scaleY) \* 0.2;  
if( current\_mc.scaleX \< default\_tn\_scale )  
current\_mc.scaleX = current\_mc.scaleY = default\_tn\_scale;  
}  
}  
else  
{  
for( j = 0; j \< thumbnail\_group.numChildren; j++ )  
{  
current\_mc = MovieClip(thumbnail\_group.getChildAt(j));  
current\_mc.scaleX += (default\_tn\_scale - current\_mc.scaleX) \* 0.2;  
current\_mc.scaleY += (default\_tn\_scale - current\_mc.scaleY) \* 0.2;  
}  
}  
}
