Hi codegurus:)
my problem is the following I have a multiple image gallery, everything is working fine, the only little problem is that I have a counter in the flash that displays the current imagenumber of the gallery that the user is looking at.
Now I can display the total number of frames in the selected gallery abut don’t know how to code the current picture number…
check out the examplehttp://www.basickonyha.hu/code
The problem is actually at the bottom of the code!
Thank you in advance for your help :te:
spacing = 10;
containerMC._alpha = 0;
var pArray = new Array();
var tArray = new Array();
//add description field
var descArray = new Array();
//
var cur;
MovieClip.prototype.loadPic = function(pic) {
clearInterval(id);
containerMC._alpha = 0;
this.loadMovie(pArray[pic]);
cur = pic;
this._parent.onEnterFrame = function() {
var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
bar._visible = 1;
per = Math.round((l/t)*100);
if (l == t && containerMC._width>0 && containerMC._height>0) {
var w = containerMC._width+spacing, h = containerMC._height+spacing;
border.resizeMe(w, h);
bar._visible = 0;
picinfo.info.text = tArray[pic];
//add description field
pic_desc.info.text = descArray[pic];
//
delete this.onEnterFrame;
} else {
bar._width = per;
//gives the bar a max width 100
//picinfo.info.text = per+" % loaded";
}
};
};
MovieClip.prototype.resizeMe = function(w, h, pic) {
//trace(w);
var speed = 3;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
prevb._x = Math.round(this._x-this._width/2)-10;
nextb._x = Math.round(this._x-this._width/2)+this._width+10;
nextb._y = prevb._y=this._y/*-(this._height/2);*/
//+(this._height/2)-10;
//picinfo._y = nextb._y-5;
//picinfo._x = border._x-picinfo._width/2;
if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1) {
this._width = w;
this._height = h;
containerMC._x = this._x-this._width/2+spacing/2;
containerMC._y = this._y-this._height/2+spacing/2;
containerMC._alpha = 100;
delete this.onEnterFrame;
}
};
};
function galleryChoice(a) {
cur = 0;
pArray = new Array();
tArray = new Array();
descArray = new Array();
var gallery_xml = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success) {
if (success) {
var gallery = this.firstChild.childNodes[a];
for (var i = 0; i<gallery.childNodes.length; i++) {
descArray.push(gallery.childNodes*.attributes.description);
tArray.push(gallery.childNodes*.attributes.title);
pArray.push(gallery.childNodes*.attributes.source);
}
//loading first picture
id = setInterval(containerMC, "loadPic", 100, 0);
picture_num();
} else {
picinfo.text = "Hiba történt...";
}
};
gallery_xml.load("front_gall.xml");
}
prevb.onRelease = function() {
cur--;
if (cur<0) {
containerMC.loadPic(pArray.length-1);
picture_num();
} else {
containerMC.loadPic(cur);
}
};
nextb.onRelease = function() {
cur++;
if (cur>pArray.length-1) {
containerMC.loadPic(0);
picture_num();
} else {
containerMC.loadPic(cur);
}
};
//////////////////////////////////////////////////////////////
////The picture number fuction is not working
////I can tell the total number of pictures in a gallery
////but not calculate the number of loaded image position
////THANK YOU FOR YOUR HELP!!!
/////////////////////////////////////////////////////////////
function picture_num() {
current_pos = cur+1;
pos_txt.text = current_pos+" / "+pArray.length;
}
galleryChoice(0);