I have the next code:
Im trying to make a preloader for the image that gets loaded in a movieclip called picholder,
Now the problem is that i get undefined back for the image ,
so i cannot preload what is not there hehe
and im not sure what im doing wrong .
In my other fla the image passes fine and the code is the same
trace(tes.picholder);
gives me back undefined
where tes is the movieclip i created for each item
picholder is the movieclip where the picture goes in.
(i have put stop() in there and taken it out to test but with no luck)
The code is
MovieClip.prototype.makeVisible = function() {
clearInterval(this.interval);
this._visible = true;
this.play()
};
function LoadPicInMovie (thepic ,wherein)
{
//wherein._alpha = 0;
trace (thepic);
trace (wherein);
var totalbytes = wherein.getBytesTotal();
var loadedbytes = wherein.getBytesLoaded();
var percentloaded = Math.ceil((loadedbytes/totalbytes)*100);
trace(percentloaded);
wherein.preloadertxt.text = percentloaded;
if (percentloaded == 100)
{
wherein.loadMovie(thepic);
}
}
function clearAll() {
for (var obj in moviecl) {
if (typeof moviecl[obj] == "movieclip") {
clearInterval(moviecl[obj].interval)
moviecl[obj].removeMovieClip();
}
}
}
function AttachMc(counter)
{
tes = GalleryContainer.attachMovie("Holder","item"+counter, counter);
return tes;
}
function List (howmany,Arr)
{
counter = 0;
item_spacing = 160;
luck = 0;
row = 0;
for (var g=0; g < howmany ; g++)
{
var tes = AttachMc(counter);
trace(tes);// fine
LoadPicInMovie(Arr["Clientimages"][g],tes.picholder);
trace(tes.picholder);// undefined
if (luck == 3)
{
row++;
luck=0;
}
tes._x = luck * item_spacing;
tes._y = 140 * row;
trace (counter);
tes.stop()
tes._visible = false;
tes.interval = setInterval(tes, "makeVisible", 500*g);
counter++;
luck++;
}
}
function PutInArray(my_xml)
{
/*
* This function reads the xml file into an array
*
*/
var item_count = 0;
// start with the first item in the XML
var items = my_xml.firstChild.firstChild.childNodes; // menu -> menuitems -> child nodes array
var total = items.length
// create arrays for the values
var TheClients:Array = new Array();
TheClients["Clientids"] = [];
TheClients["Clientnames"] = [];
TheClients["Clientdescriptions"] = [];
TheClients["Clientimages"] = [];
TheClients["Clientdates"] = [];
TheClients["Totaal"] = total;
for (var i=0; i< total; i++) {
// only continue if the type of this item is a squirrel
// create variables for our elements
var clientid = items*.firstChild; // same as items*.childNodes[0]
var clientname = items*.childNodes[1]; // second child node
var clientdescription = items*.childNodes[2];
var clientimage = items*.childNodes[3];
var clientdate = items*.childNodes[4];
// add to array
TheClients["Clientids"]* = clientid.firstChild.nodeValue;
TheClients["Clientnames"]* = clientname.firstChild.nodeValue;
TheClients["Clientdescriptions"]* = clientdescription.firstChild.nodeValue;
TheClients["Clientimages"]* = clientimage.firstChild.nodeValue;
TheClients["Clientdates"]* = clientdate.firstChild.nodeValue;
item_count++;
}
return TheClients;
}
// start procedural code
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success){
if (success){
Client = PutInArray(my_xml);
List (9,Client);
trace(this);
} else{
trace('xml file not loaded');
}
}
my_xml.load("portfolio.xml");
stop();
Thanks in advance
Luck