PDA

View Full Version : help with xml -handling html


yank crime
04-11-2007, 04:23 PM
Greetings. I'm working on a sort of portfolio based project/image gallery. There are thumbnails- and the full version images, and a dynamic text field.

I've got everything working. However my xml experience is limited at best. I'm trying to include a url in the description text. - to no avail.

I've set the text field to html- both by clicking the <> button- as well as in the AS... no luck. with just adding an <a href=... tag in the xml i get a 'null' returned in the swf. while including- <![CDATA[<a HREF= in the description tag... i get the copy into the text field- but just as static text... reading the entire link" <a href...

if anyone can help out- this seems like it's something simple i'm missing or not getting, but it's causing me to pull my hair something wild.

Thanks so much for your time!

-matt

CyanBlue
04-11-2007, 05:51 PM
Howdy and Welcome... :)

You've got to show us what you have... What's your AS look like???

yank crime
04-13-2007, 06:20 PM
Thanks so much for the reply. I've had a bit of a crazy week and haven't had a chance to get back to this.

I'm working from a tutorial i found on kirupa.com for creating a gallery w/ thumbs and a full image- as well as a text field- all pulled from an external .xml file. What I can't seem to make happen is I'd like the text field to contain a url.

here is my as, and then after that I'll paste the xml file. Thanks so much for the help!

-Matt


main_menu.boton1._visible=false;
main_menu.boton2._visible=false;
main_menu.boton_reset._visible=false;

////////////////////////////////////////////////////////////////////////////////////

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
_global.total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnailer(i);
}
firstImage();
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad =loadXML;
xmlData.load("images.xml");

/////////Load First Image Function///////////////////////////////////////////////

function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
}
}

/////////Image Preloader Function//////////////////////////////////////////////////////

p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};

//////////Load clicked thumbnail Image Function////////////////////////////////////////////////

function callImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
}
}

//////////Thumbnail maker///////////////////////////////

function thumbnailer(k){
loaded_counter=0;
total_thumbs = _global.total;
var container = thumbnail_mc.createEmptyMovieClip("th"+k,thumbnail_mc.getNextHighestDepth());
container._visible=false;
container._alpha=0;
var image = container.createEmptyMovieClip("img", container.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue;
callImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
loaded_counter++;
counting_txt = loaded_counter;
if(loaded_counter==total_thumbs){
main_menu.boton1._visible=false;
main_menu.boton2._visible=false;
grid_maker_01();
}
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.th"+k+".img");
}

///////////Layout Functions/////////////////////////////////////////////////////////////////////

MovieClip.prototype.grid_maker_01=function(f){
num=0;
col=3;
row=3;
scale=60;
space=5;
for (l=0;l<col;l++){
for (j=0;j<row;j++){
if(num<_global.total){
with(eval("this.thumbnail_mc.th"+num)){
_x=((_width+space)*scale/100)*l;
_y=((_height+space)*scale/100)*j;
_xscale=_yscale=scale;
_visible=true;
}
num++;
}
}
}
this.cascader();
}

//////////////////////////////////////////////////////////////////////////////////

MovieClip.prototype.cascader=function(){
inter=300;
c=0;
delayed_fade=function(){
if (c<_global.total){
with(eval("this.thumbnail_mc.th"+c)){
fadein();
}
c++;
}else{
main_menu.boton_reset._visible=true;
clearInterval(delay);
}
}
delay=setInterval(delayed_fade,inter);
}

///////////////////////////////////////////////////////////////////////////////

MovieClip.prototype.fadein=function(){
this.onEnterFrame=function(){
if (this._alpha<100){
this._alpha=this._alpha+5;
}else{
this._alpha=100;
delete this.onEnterFrame;
}
}
}

///////////////////////////////////////////////////////////////////////////////////////

MovieClip.prototype.positioner = function(xDest,yDest,rDest,aDest){
this.onEnterFrame=function(){
this._x = xDest-(xDest-this._x)/1.2;
this._y = yDest-(yDest-this._y)/1.2;
this._alpha = aDest-(aDest-this._alpha)/1.2;
this._rotation = rDest-(rDest-this._rotation)/1.2;
if((Math.abs(xDest-this._x) <= 1)and(Math.abs(yDest-this._y) <= 1)){
delete this.onEnterFrame;
this._x = xDest;
this._y = yDest;
this._alpha = aDest;
this._rotation = rDest;
}
}
}

//////////////////////////////////////////////////////////////////////////////////

MovieClip.prototype.grid_maker_02=function(){
t=0;
num=0;
col=3;
row=4;
scale=80;
space=10;
x_offset=100;
y_offset=0;
inter=300;
function array_maker(){
_global.j_array= new Array();
_global.l_array= new Array();
for(l=0;l<row;l++){
for(j=0;j<col;j++){
r=_global.j_array.push(j);
q=_global.l_array.push(l);
}
}
}
array_maker();
function mover(){
if(t<_global.total){
n=_global.j_array[t];
m=_global.l_array[t]
with(eval("this.thumbnail_mc.th"+t)){
xD=x_offset+((_width+space)*scale/100)*n;
yD=y_offset+((_height+space)*scale/100)*m;
rD=0;
aD=100;
_xscale=_yscale=scale;
_visible=true;
positioner(xD,yD,rD,aD);
}
}else{
clearInterval(delay2);
main_menu.boton_reset._visible=true;
}
t++;
}
delay2=setInterval (mover,inter);
}

/////////////////////////////////////////////////////////////////////////

function reset(){
for(d=0;d<_global.total;d++){
with(eval("this.thumbnail_mc.th"+d)){
_x=0;
_y=0;
_alpha=0;
_xscale=100;
_yscale=100;
_rotation=0;
visible=false;
}
}
}

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>featWork/full/brand.jpg</image>
<caption>Website: brandtson.com</caption>
<thumbnail>featWork/thumbs/brand.jpg</thumbnail>
</pic>
<pic>
<image>featWork/full/wbt.jpg</image>
<caption>E-Card: Westbound Train</caption>
<thumbnail>featWork/thumbs/wbt.jpg</thumbnail>
</pic>
</images>