# Photoalbum with categories

**URL:** https://forum.kirupa.com/t/photoalbum-with-categories/230669
**Category:** Uncategorized
**Created:** [June 28, 2007, 3:38am UTC](https://forum.kirupa.com/t/photoalbum-with-categories/230669 "2007-06-28T03:38:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gooddesi](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@gooddesi](https://forum.kirupa.com/u/gooddesi)
#### Post date: [June 28, 2007, 3:38am UTC](https://forum.kirupa.com/t/photoalbum-with-categories/230669/1 "2007-06-28T03:38:16Z")

</div>

I have created a photo album with categories. but i have to click “category1” button two times to load the thumbnail. on first click it hide the thumbnail and 2nd click it shows the thumbnail.

flowing is the code and let me know where i am doing wrong.  
CODE:-

info.text = “Loading…”;  
my\_xml = new XML ();  
my\_xml.ignoreWhite = true;  
my\_xml.load (“images.xml”);  
\_root.image = 0;  
LastitemTotal = 0;  
category = “Its Me”;  
my\_xml.onLoad = function (status)  
{  
if (status)  
{  
\_root.levelChild = this.firstChild;  
category\_fn (category);  
var mcl:MovieClipLoader = new MovieClipLoader ();  
var picListener:Object = new Object ();  
mcl.addListener (picListener);  
mcl.loadClip (info\_xml[0].attributes.source, pic1);  
info.text = info\_xml[0].attributes.title;  
picListener.onLoadInit = function (mc:MovieClip)  
{  
setPicture (image);  
};  
}  
ZoomOut.\_visible = false;  
ZoomOutText.\_visible = false;  
ZoomInText.\_visible = true;  
};

function setPicture (image)  
{  
this.onEnterFrame = function ()  
{  
if (pic1.\_width \> 0)  
{  
var mcl:MovieClipLoader = new MovieClipLoader ();  
var picListener:Object = new Object ();  
mcl.addListener (picListener);  
mcl.loadClip (info\_xml[image].attributes.source, pic1);  
info.text = info\_xml[image].attributes.title;  
picListener.onLoadInit = function (mc:MovieClip)  
{  
if (mc.\_height \> mc.\_width)  
{  
mc.\_height = 520;  
mc.\_width = 420;  
stageWidth = 640;  
stageHeight = 560;  
mc.\_x = 27 + (stageWidth - mc.\_width) / 2;  
mc.\_y = 40 + (stageHeight - mc.\_height) / 2;  
pic1.\_alpha = 100;  
}  
else  
{  
mc.\_height = 520;  
mc.\_width = 620;  
mc.\_x = 32;  
mc.\_y = 55;  
}  
};  
ZoomInText.\_visible = true;  
ZoomIn.\_visible = true;  
ZoomOutText.\_visible = false;  
ZoomOut.\_visible = false;  
Frame.\_visible = true;  
delete my\_xml;  
delete this.onEnterFrame;  
\_root.image = image;  
}  
};  
}  
ZoomIn.onRelease = function ()  
{  
image = \_root.image;  
var mcl:MovieClipLoader = new MovieClipLoader ();  
var picListener:Object = new Object ();  
mcl.addListener (picListener);  
mcl.loadClip (info\_xml[image].attributes.source, pic1);  
info.text = info\_xml[image].attributes.title;  
picListener.onLoadInit = function (mc:MovieClip)  
{  
ZoomIn.\_visible = false;  
ZoomInText.\_visible = false;  
ZoomOutText.\_visible = true;  
ZoomOut.\_visible = true;  
Frame.\_visible = false;  
thumbnail\_mc.enabled = false;  
thumbnail\_mc.\_visible = false;  
if (mc.\_height \> mc.\_width)  
{  
mc.\_height = 575;  
mc.\_width = 450;  
stageWidth = 800;  
stageHeight = 600;  
mc.\_x = 2 + (stageWidth - mc.\_width) / 2;  
mc.\_y = 2 + (stageHeight - mc.\_height) / 2;  
pic1.\_alpha = 100;  
}  
else  
{  
mc.\_height = 550;  
mc.\_width = 750;  
stageWidth = 800;  
stageHeight = 600;  
mc.\_x = 10 + ((stageWidth - mc.\_width) / 2);  
mc.\_y = 10 + ((stageHeight - mc.\_height) / 2);  
}  
};  
delete my\_xml;  
delete this.onEnterFrame;  
};  
ZoomOut.onRelease = function ()  
{  
delete this.onEnterFrame;  
setPicture (image);  
ZoomInText.\_visible = true;  
ZoomIn.\_visible = true;  
ZoomOutText.\_visible = false;  
ZoomOut.\_visible = false;  
thumbnail\_mc.enabled = true;  
thumbnail\_mc.\_visible = true;  
};  
function thumbNailScroller ()  
{  
// thumbnail code!  
this.createEmptyMovieClip (“tscroller”, 1000);  
scroll\_speed = 10;  
tscroller.onEnterFrame = function ()  
{  
if ((\_root.\_xmouse \>= thumbnail\_mc.\_x) && (\_root.\_xmouse \<= thumbnail\_mc.\_x + thumbnail\_mc.\_width))  
{  
if ((\_root.\_ymouse \>= (hit\_right.\_y - 40)) && (thumbnail\_mc.hitTest (hit\_right)))  
{  
thumbnail\_mc.\_y -= scroll\_speed;  
}  
else if ((\_root.\_ymouse \<= 100) && (thumbnail\_mc.hitTest (hit\_left)))  
{  
thumbnail\_mc.\_y += scroll\_speed;  
}  
}  
else  
{  
delete tscroller.onEnterFrame;  
}  
};  
}  
Category0.onRelease = function ()  
{  
category\_fn (“Gods”);  
setPicture (0);  
};  
Category1.onRelease = function ()  
{  
category\_fn (“Its Me”);  
setPicture (0);  
};  
function category\_fn (category)  
{

```
Total = _root.levelChild.childNodes.length;
for (attr = 0; attr &lt; Total; attr++)
{
    if (_root.levelChild.childNodes[attr].attributes.Menu == category)
    {
        //then count and loop through items in category until found specific item
        itemTotal = _root.levelChild.childNodes[attr].childNodes.length;
        info_xml = _root.levelChild.childNodes[attr].childNodes;
        thumbnails = new Array ();
        if (itemTotal &lt; LastitemTotal)
        {
            unloadclips ();
        }
        for (i = 0; i &lt; itemTotal; i++)
        {
            thumbnails* = info_xml*.attributes.thumbnail;
            thumbnails_fn (i);
        }
    }
}
LastitemTotal = itemTotal;

```

}  
function unloadclips ()  
{  
thumbnail\_mc.unloadMovie ();  
LastitemTotal = itemTotal - 1;  
image\_mcl = new MovieClipLoader ();  
image\_mcl.loadClip (thumbnails, thumbnail\_mc);  
this.thumbnail\_mc.refresh;  
this.clear;  
}  
function thumbnails\_fn (k)  
{  
thumbnail\_mc.createEmptyMovieClip (“t” + k, thumbnail\_mc.getNextHighestDepth ());  
tlistener = new Object ();  
tlistener.onLoadInit = function (target\_mc)  
{  
target\_mc.\_y = hit\_left.\_y + (eval (“thumbnail\_mc.t” + k).\_height + 5) \* k;  
target\_mc.pictureValue = k;  
target\_mc.onRelease = function ()  
{  
p = this.pictureValue;  
// Draw Picture  
setPicture §;  
};  
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);  
}
