Groups | Blog | Home
all groups > flash actionscript > february 2007 >

flash actionscript : XML Photo Gallery


GAMBRKER
2/18/2007 11:38:00 PM
First off, please don't be mad that I am using a template. I dont know where to
start creating an XML gallery from scratch. Anyway, I've customized one, and
have found that it works fine if it is just the .swf by itself. HOWEVER, if I
load the swf into a movie clip, or if I mask it, it gets all jacked up. The
pictures still show up, but the thumbnail functionality is what doesn't work
right. You can see for yourself:

http://www.yourtimelesswedding.com/works

http://www.yourtimelesswedding.com/doesntwork

My reason for putting it into a new clip is because I'm am loading it into a
main swf. I am sure it may be in the code but don't really know where to look.
Any help is greatly appreciated. Below is the only action script in the fla.



function loadPhotoXML(filename)
{
PhotoXML.ignoreWhite = true;
PhotoXML.load(filename);
PhotoXML.onLoad = function (success)
{
if (success)
{
PhotoNumber = 0;
RootNode = this.firstChild;
TotalPhotos = RootNode.childNodes.length;
thumbnails = [];
for (i = 0; i < TotalPhotos; i++)
{
thumbnails[i] =
RootNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails_fn(i);
} // end of for
showPhoto(PhotoNumber);
} // end if
};
} // End of the function
function showPhoto(PhotoNum)
{
if (PhotoNum == TotalPhotos - 1)
{
next_btn.enabled = false;
}
else
{
next_btn.enabled = true;
} // end else if
if (PhotoNum == 0)
{
previous_btn.enabled = false;
}
else
{
previous_btn.enabled = true;
} // end else if
if (loaded == filesize)
{
var _loc2 = RootNode.childNodes[PhotoNum].attributes.filename;
var _loc3 = RootNode.childNodes[PhotoNum].firstChild.nodeValue;
empty_mc.loadMovie("photos/" + _loc2);
} // end if
} // End of the function
function nextImage()
{
if (p < TotalPhotos - 1)
{
PhotoNumber = PhotoNumber + 1;
if (loaded == filesize)
{
empty_mc._alpha = 0;
showPhoto(PhotoNumber);
} // end if
} // end if
} // End of the function
function prevImage()
{
PhotoNumber = PhotoNumber - 1;
showPhoto(PhotoNumber);
} // End of the function
function thumbNailScroller()
{
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 10;
tscroller.onEnterFrame = function ()
{
if (_root._ymouse >= thumbnail_mc._y && _root._ymouse <=
thumbnail_mc._y + thumbnail_mc._height)
{
if (_root._xmouse >= hit_right._x - 40 &&
thumbnail_mc.hitTest(hit_right))
{
thumbnail_mc._x = thumbnail_mc._x - scroll_speed;
}
else if (_root._xmouse <= 40 && thumbnail_mc.hitTest(hit_left))
{
thumbnail_mc._x = thumbnail_mc._x + scroll_speed;
} // end else if
else
{
delete tscroller.onEnterFrame;
} // end else if
}
};
} // End of the function
function thumbnails_fn(k)
{
thumbnail_mc.createEmptyMovieClip("t" + k,
thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function (target_mc)
{
target_mc._x = hit_left._x + (eval("thumbnail_mc.t" + k)._width + 2) *
k;
target_mc.pictureValue = k;
target_mc.onRelease = function ()
{
PhotoNumber = this.pictureValue - 1;
nextImage();
};
target_mc.onRollOver = function ()
{
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function ()
{
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t" + k);
} // End of the function
p = 0;
var PhotoXML = new XML();
var PhotoNumber;
var TotalPhotos;
var RootNode;
loadPhotoXML("photos.xml");
listen = new Object();
listen.onKeyDown = function ()
{
if (Key.getCode() == 37)
{
prevImage();
}
else if (Key.getCode() == 39)
{
nextImage();
} // end else if
};
this.onEnterFrame = function ()
{
filesize = empty_mc.getBytesTotal();
loaded = empty_mc.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize)
{
preloader.preload_bar._xscale = 100 * loaded / filesize;
}
else
{
preloader._visible = false;
if (empty_mc._alpha < 100)
{
empty_mc._alpha = empty_mc._alpha + 10;
} // end if
} // end else if
};
Key.addListener(listen);
previous_btn.onRelease = function ()
{
prevImage();
};
next_btn.onRelease = function ()
{
nextImage();
};
GAMBRKER
2/20/2007 2:50:37 PM
LuigiL
2/20/2007 2:59:13 PM
Try locking the root in the 'child' swf.
First line of the code:
stwingy
2/20/2007 6:11:07 PM
Your template looks decompiled but is freely available at Kirupa.com. May work
if you follow above suggestion but if you remove all occurences of
"_root."from thumbNailScroller function , it should also work

GAMBRKER
2/27/2007 12:10:40 AM
AddThis Social Bookmark Button