I’ve got xml photo gallery which you can see at www.suziklinik.cz under the “Galerie”.
Everything works pretty fine until I update the xml code with more then 5 albums. When I do that…for ex. I choose “album 2 or 3” and then I choose thumb/picture 1st or 2nd it always jumps to last album…why?
here is the flash code
this._lockroot = true;
//////////////////////////////////////////////////////////////
// SETTING VARIABLES
currentpage = 1;
_global.whichalbum = 1;
//////////////////////////////////
function scalerf(w,h)
{
diffw = (w-bigframew);
diffh = (h-bigframeh);
if(diffw<=0&&diffh<=0)
{
scaler = 1 * 100;
}
else if (diffw==Math.max(diffw,diffh)) //scale to height
{
scaler = (bigframew/w) * 100;
}
else if (diffh==Math.max(diffw,diffh)) //scale to width
{
scaler = (bigframeh/h) * 100;
}
return scaler;
}
//LOADCLIP ACTIVITIES
_root.createEmptyMovieClip("looploop",-1000);
var my_mcl = new MovieClipLoader();
myListener = new Object();
myListener.onLoadStart = function (target_mc)
{
var loadProgress = my_mcl.getProgress(target_mc);
}
myListener.onLoadProgress = function (target_mc, loadedBytes, totalBytes)
{
////////////////////////////////////////////////////////
// FOR PRELOADER PURPOSES
loaded = loadedBytes;
total = totalBytes;
percentage = Math.round(100*(loaded/total));
progressbar_mc.progresser_mc._xscale = percentage;
////////////////////////////////////////////////////////
}
myListener.onLoadComplete = function (target_mc)
{
var loadProgress = my_mcl.getProgress(target_mc);
imageframe_mc.hold._alpha=0;
velo = 0;
imageframe_mc.hold.onEnterFrame = function()
{
w = imageframe_mc.hold._width;
h = imageframe_mc.hold._height;
if(w!=0&&h!=0)
{
scaler = scalerf(w,h);
if(scaler!=100)
{
imageframe_mc.hold._xscale = scaler;
imageframe_mc.hold._yscale = scaler;
}
imageframe_mc.hold._x = (bigframew - (w*(scaler/100)))/2;
imageframe_mc.hold._y = -1+(bigframeh - (h*(scaler/100)))/2;
if(imageframe_mc.hold._alpha<100)
{
accel = 0.3;
velo = velo + accel;
imageframe_mc.hold._alpha +=velo;
}
}
}
}
myListener.onLoadInit = function (target_mc)
{
//target_mc._width = 100;
//target_mc._width = 100;
}
myListener.onLoadError = function (target_mc, errorCode)
{
}
my_mcl.addListener(myListener);
///////////////////////////////////////////////////////////////
// XML PARSING
function imageListLoaded(whichalbum) {
//clear stage
for (var rr = 0; rr < noofrow * noofcolumn; rr++)
{
rr = rr + pageindex;
this["thumbframe"+rr].removeMovieClip();
this["thumbframein_mc"+rr].removeMovieClip();
rr = rr - pageindex;
}
//parameters
param = this.imageList_xml.firstChild.firstChild;
pc = int(param.attributes.noofcolumn);
pr = int(param.attributes.noofrow);
ptx = int(param.attributes.thumbxs);
pty = int(param.attributes.thumbys);
_global.ptw = int(param.attributes.thumbwidth);
_global.ptl = int(param.attributes.thumbheight);
_global.bigframew = int(param.attributes.bigframewidth);
_global.bigframeh = int(param.attributes.bigframeheight);
albumnamesx = int(param.attributes.albumnamesxs);
albumnamesy = int(param.attributes.albumnamesys);
albumnamescolor = param.attributes.albumnamescolor;
//////////////////////////////////////////////////////////////
var albumCountXML = this.imageList_xml.firstChild.childNodes;
albumCount = albumCountXML.length - 1;
var mainNode = this.imageList_xml.firstChild.childNodes[whichalbum].firstChild;
var listBoxData = createResourceList (mainNode.childNodes,pc,pr,ptx,pty,ptw,ptl);
//////////////////////////////////////////////////////////////////
// Number of Album
albumtextbox.text = "Album "+whichalbum+">>>";
albumtextbox.background = true;
albumtextbox.backgroundColor = 0xF0CC64;
for (t=1;t<=albumCount;t++)
{
category.text = "A L B U M Y";
//category.background = true;
category.backgroundColor = 0xF0CC64;
/////////////////////////////////////////////////////////////
//Creating text box
this.createEmptyMovieClip("albumnames"+t,900+t);
albumname_mc = this["albumnames"+t];
albumname_mc.createTextField("albumnametxt"+t,1000+t,0,0,200,200);
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = albumnamescolor;
my_fmt.font = "Tahoma"
my_fmt.size = 11;
albumname_mc["albumnametxt"+t].text = this.imageList_xml.firstChild.childNodes[t].attributes.albumname;
albumname_mc["albumnametxt"+t].setTextFormat(my_fmt);
albumname_mc._x = albumnamesx;
albumname_mc._y = albumnamesy + t * 15;
albumname_mc.sett = t;
albumname_mc.onRelease = function()
{
currentpage = 1;
filename.text = "";
for (var rr = 0; rr < noofrow * noofcolumn; rr++)
{
rr = rr + pageindex;
this["thumbframe"+rr].removeMovieClip();
this["thumbframein_mc"+rr].removeMovieClip();
rr = rr - pageindex;
}
imageListLoaded(this.sett)
_global.whichalbum = this.sett;
}
}
}
function createResourceList(resource_array,noofcolumn,noofrow,thumbxs,thumbys,thumbwidth,thumblength,bigimagewidth) {
_global.noofcolumn = noofcolumn;
_global.noofrow = noofrow;
var listData = new DataProviderClass ();
resourceCount = resource_array.length;
noofpage = Math.ceil(resourceCount/(noofcolumn*noofrow));
ofof.text = "strana: "+currentpage+"/"+noofpage;
ofof.background = true;
ofof.backgroundColor = 0xF0CC64;
var resource, image, tmb;
images = new Array();
infotexts = new Array();
pageindex =((currentpage-1) * noofrow * noofcolumn);
for (var r = 0; r < noofrow; r++)
{
for (var c = 0; c < noofcolumn; c++) {
i = (r * noofcolumn) + c + pageindex;
if(i<resourceCount)
{
nodigits = new String(resourceCount);
resource = resource_array*;
images* = resource.attributes.imagename;
infotexts* = resource.attributes.infotext;
loadme = "flashimg/thmb/"+images*;
findme = images*;
whichframe = "frame"+i;
this.attachMovie("thumbframe","thumbframe"+i,i+1);
this["thumbframe"+i]._x = (c * thumbwidth)+thumbxs;
this["thumbframe"+i]._y = (r * thumblength)+thumbys;
createEmptyMovieClip("thumbframein_mc"+i,(i+1)*1000);
onEnterFrame = function()
{
for (var tr = 0; tr < noofrow; tr++)
{
for (var tc = 0; tc < noofcolumn; tc++) {
ti = (tr * noofcolumn) + tc + pageindex;
if(ti<resourceCount)
{
tw = this["thumbframein_mc"+ti]._width;
th = this["thumbframein_mc"+ti]._height;
this["thumbframein_mc"+ti]._x = this["thumbframe"+ti]._x+(thumbwidth - tw)/2;
this["thumbframein_mc"+ti]._y = this["thumbframe"+ti]._y+(thumblength - th)/2;
}
}
}
}
this["thumbframein_mc"+i].loadMovie(loadme);
noofthumbs = (currentpage-1) * noofcolumn * noofrow;
nom = noofthumbs;
callbig(nom);
this.filename.text = " "+images[nom];
this["thumbframe"+i].onPress = function()
{
startsubstring = 10;
endsubstring = startsubstring + nodigits.length;
largeindex=this._name.substring(startsubstring,endsubstring);
callbig(largeindex);
}
}
}
}
}
function callbig(index)
{
filename.text = " "+images[index];
info.text = infotexts[index];
imageframe_mc.createEmptyMovieClip("hold",0);
imageframe_mc.pictoral._width = _global.bigframew + 3;
imageframe_mc.pictoral._height = _global.bigframeh;
my_mcl.loadClip("flashimg/img/"+images[index],this.imageframe_mc.hold);
imageframe_mc.onPress = function()
{getURL("flashimg/pics/"+images[index],"_blank");}
}
imageList_xml = new XML ();
imageList_xml.ignoreWhite = true;
imageList_xml.onLoad = function (success) {
if (success) {
imageListLoaded(whichalbum);
}
};
//////////////////////////////////////////
//HERE IS WHERE YOU DECLARE YOUR XML FILE
imageList_xml.load ("albums.xml");
//////////////////////////////////////////
rightbt.onRelease=function()
{
if(currentpage != noofpage)
{
currentpage ++;
imageListLoaded(_global.whichalbum);
}
}
leftbt.onRelease=function()
{
if(currentpage > 1)
{
currentpage --;
imageListLoaded(_global.whichalbum);
}
}
stop();
and for any case here is xml code
<!--
bigframeheight: the top big frame's height
bigframewidth: the top big frame's width
noofcolumn: number of columns for the thumbnails
noofrow: number of row for the thumbnails
thumbxs: x coordinate of thumbnails matrix(topleft)
thumbys: y coordinate of thumbnails matrix(topleft)
thumbwidth: a single thumbnail holder's width
thumbwidth: a single thumbnail holder's height
albumnamesxs: x coordinate of albumnames' list
albumnamesys: y coordinate of albumnames' list
albumnamescolor: Color code for albumnames' texts
-->
<photoalbum>
<parameters bigframeheight = "264" bigframewidth = "451" noofcolumn="8" noofrow="1" thumbxs="10" thumbys="275" thumbwidth="74" thumbheight="73" albumnamesxs="0" albumnamesys="0" albumnamescolor="0xF0CC64"/>
<album albumname="1 ~ Jeep">
<images>
<image imagename="jeep0001.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0002.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0003.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0004.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0005.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0006.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0007.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0008.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0009.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0010.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0011.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0012.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0013.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0014.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0015.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0016.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0017.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0018.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0019.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0020.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0021.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0022.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0023.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0024.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0025.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0026.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0027.jpg" infotext="Jeep Restaurování"/>
<image imagename="jeep0028.jpg" infotext="Jeep Restaurování"/>
</images>
</album>
<album albumname="2 ~ Motor 1.3 ">
<images>
<image imagename="engine0001.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
<image imagename="engine0002.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
<image imagename="engine0003.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
<image imagename="engine0004.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
<image imagename="engine0005.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
<image imagename="engine0006.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
<image imagename="engine0007.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
<image imagename="engine0008.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
<image imagename="engine0009.jpg" infotext="Suzuki Samurai 1.3 Restaurování"/>
</images>
</album>
<album albumname="3 ~ V Akci">
<images>
<image imagename="action0001.jpg" infotext="V Akci" />
<image imagename="action0002.jpg" infotext="V Akci" />
<image imagename="action0003.jpg" infotext="V Akci" />
<image imagename="action0004.jpg" infotext="V Akci" />
<image imagename="action0005.jpg" infotext="V Akci" />
<image imagename="action0006.jpg" infotext="V Akci" />
<image imagename="action0007.jpg" infotext="V Akci" />
<image imagename="action0008.jpg" infotext="V Akci" />
</images>
</album>
<album albumname="4 ~ Ford Transit">
<images>
<image imagename="transit0001.jpg" infotext="" />
<image imagename="transit0002.jpg" infotext="" />
<image imagename="transit0003.jpg" infotext="" />
<image imagename="transit0004.jpg" infotext="" />
<image imagename="transit0005.jpg" infotext="" />
</images>
</album>
<album albumname="5 ~ Transit po Požáru">
<images>
<image imagename="fire0001.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0002.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0003.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0004.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0005.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0006.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0007.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0008.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0009.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0010.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0011.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0012.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0013.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0014.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0015.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0016.jpg" infotext="Ford Transit po Požáru" />
<image imagename="fire0017.jpg" infotext="Ford Transit po Požáru" />
</images>
</album>
<album albumname="6 ~ Projekt Tatarak">
<images>
<image imagename="tatarak0001.jpg" infotext="" />
<image imagename="tatarak0002.jpg" infotext="" />
<image imagename="tatarak0003.jpg" infotext="" />
<image imagename="tatarak0004.jpg" infotext="" />
<image imagename="tatarak0005.jpg" infotext="" />
<image imagename="tatarak0006.jpg" infotext="" />
<image imagename="tatarak0007.jpg" infotext="" />
<image imagename="tatarak0008.jpg" infotext="" />
<image imagename="tatarak0009.jpg" infotext="" />
<image imagename="tatarak0010.jpg" infotext="" />
<image imagename="tatarak0011.jpg" infotext="" />
<image imagename="tatarak0012.jpg" infotext="" />
<image imagename="tatarak0013.jpg" infotext="" />
<image imagename="tatarak0014.jpg" infotext="" />
<image imagename="tatarak0015.jpg" infotext="" />
<image imagename="tatarak0016.jpg" infotext="" />
<image imagename="tatarak0017.jpg" infotext="" />
<image imagename="tatarak0018.jpg" infotext="" />
<image imagename="tatarak0019.jpg" infotext="" />
<image imagename="tatarak0020.jpg" infotext="" />
<image imagename="tatarak0021.jpg" infotext="" />
<image imagename="tatarak0022.jpg" infotext="" />
<image imagename="tatarak0023.jpg" infotext="" />
<image imagename="tatarak0024.jpg" infotext="" />
<image imagename="tatarak0025.jpg" infotext="" />
<image imagename="tatarak0026.jpg" infotext="" />
<image imagename="tatarak0027.jpg" infotext="" />
<image imagename="tatarak0028.jpg" infotext="" />
<image imagename="tatarak0029.jpg" infotext="" />
<image imagename="tatarak0030.jpg" infotext="" />
<image imagename="tatarak0031.jpg" infotext="" />
<image imagename="tatarak0032.jpg" infotext="" />
<image imagename="tatarak0033.jpg" infotext="" />
<image imagename="tatarak0034.jpg" infotext="" />
<image imagename="tatarak0035.jpg" infotext="" />
<image imagename="tatarak0036.jpg" infotext="" />
<image imagename="tatarak0037.jpg" infotext="" />
<image imagename="tatarak0038.jpg" infotext="" />
<image imagename="tatarak0039.jpg" infotext="" />
<image imagename="tatarak0040.jpg" infotext="" />
<image imagename="tatarak0041.jpg" infotext="" />
<image imagename="tatarak0042.jpg" infotext="" />
<image imagename="tatarak0043.jpg" infotext="" />
<image imagename="tatarak0044.jpg" infotext="" />
<image imagename="tatarak0045.jpg" infotext="" />
<image imagename="tatarak0046.jpg" infotext="" />
<image imagename="tatarak0047.jpg" infotext="" />
<image imagename="tatarak0048.jpg" infotext="" />
<image imagename="tatarak0049.jpg" infotext="" />
<image imagename="tatarak0050.jpg" infotext="" />
<image imagename="tatarak0051.jpg" infotext="" />
<image imagename="tatarak0052.jpg" infotext="" />
<image imagename="tatarak0053.jpg" infotext="" />
<image imagename="tatarak0054.jpg" infotext="" />
<image imagename="tatarak0055.jpg" infotext="" />
<image imagename="tatarak0056.jpg" infotext="" />
<image imagename="tatarak0057.jpg" infotext="" />
<image imagename="tatarak0058.jpg" infotext="" />
<image imagename="tatarak0059.jpg" infotext="" />
<image imagename="tatarak0060.jpg" infotext="" />
<image imagename="tatarak0061.jpg" infotext="" />
<image imagename="tatarak0062.jpg" infotext="" />
<image imagename="tatarak0063.jpg" infotext="" />
<image imagename="tatarak0064.jpg" infotext="" />
<image imagename="tatarak0065.jpg" infotext="" />
<image imagename="tatarak0066.jpg" infotext="" />
<image imagename="tatarak0067.jpg" infotext="" />
<image imagename="tatarak0068.jpg" infotext="" />
<image imagename="tatarak0069.jpg" infotext="" />
<image imagename="tatarak0070.jpg" infotext="" />
</images>
</album>
<!--<album albumname="7 ~ Náš TUNING">
<images>
<image imagename="tuning0001.jpg" infotext="" />
<image imagename="tuning0002.jpg" infotext="" />
<image imagename="tuning0003.jpg" infotext="" />
<image imagename="tuning0004.jpg" infotext="" />
<image imagename="tuning0005.jpg" infotext="" />
<image imagename="tuning0006.jpg" infotext="" />
<image imagename="tuning0007.jpg" infotext="" />
<image imagename="tuning0008.jpg" infotext="" />
<image imagename="tuning0009.jpg" infotext="" />
<image imagename="tuning0010.jpg" infotext="" />
<image imagename="tuning0011.jpg" infotext="" />
<image imagename="tuning0012.jpg" infotext="" />
<image imagename="tuning0013.jpg" infotext="" />
<image imagename="tuning0014.jpg" infotext="" />
<image imagename="tuning0015.jpg" infotext="" />
</images>
</album>-->
<!--<album albumname="8 ~ Sady">
<images>
<image imagename="sady0001.jpg" infotext="" />
<image imagename="sady0002.jpg" infotext="" />
<image imagename="sady0003.jpg" infotext="" />
<image imagename="sady0004.jpg" infotext="" />
</images>
</album>-->
</photoalbum>
thanks guys