
Код:
var btTotal:Number = _root.fs; //общий размер
gallery_xml.onLoad = function(success:Boolean) {
try {
if (success) {
var gallery_array:Array = new Array();
for (var i = 0; i<=_root.pictures.length; i++) {
if(i==0)
{
gallery_array.push(path_album+"albums/"+album+"/"+_root.first_photo);
}
else
{
gallery_array.push(path_album+"albums/"+album+"/flash/"+_root.first_photo+"/"+_root.pictures[i-1]);
}
}
/* call the displayGallery function which handles loading in each
of the gallery images and placing them on the Stage. */
displayGallery(gallery_array);
} else {
throw new Error("Unable to parse XML");
}
} catch (e_err:Error) {
trace(e_err.message);
} finally {
delete this;
}
};
// load the gallery.xml file from the current directory.
gallery_xml.load("gallery_tween.xml");
/* create a function which loops through the images in an array,
and creates new movie clips on the Stage. */
function displayGallery(gallery_array:Array) {
var galleryLength:Number = gallery_array.length;
// loop through each of the images in the gallery_array.
for (var i = 0; i<galleryLength; i++) {
/* create a movie clip instance which holds the image. We'll also set a variable,
thisMC, which is an alias to the movie clip instance. */
var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc", i+1);
/* load the current image source into the new movie clip instance,
using the MovieClipLoader class. */
mcLoader_mcl.loadClip(gallery_array[i], thisMC);
}
}
// define the MovieClipLoader instance and MovieClipLoader listener Object.
var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
};
// while the content is preloading, modify the width of the progress bar.
mclListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
var pctLoaded:Number = Math.round(loadedBytes/totalBytes*100);
if(pctLoaded < 100)
{
varPercent = (_root.btLoaded + loadedBytes)/(_root.btTotal)*100;
}
else
{
varPercent = (_root.btLoaded + totalBytes)/(_root.btTotal)*100;
_root.btLoaded += totalBytes;
}
//trace("Процент загрузки в "+target_mc+" составляет "+varPercent+"%");
//Показываем процент загрузки в текстовых полях
anim_num.num_pr.text = Math.round(varPercent) + "%";
anim_num.num_kb.text = Math.round(_root.btLoaded) + " of " + Math.round((_root.btTotal))+" "+_root.bTotal + " kb";
};