Hi, I’m new to actionscript so this should be obvious to someone. I’m working with the http://www.kirupa.com/forum/showthread.php?t=87388 ( The gallery with multiple galleries using one xml.) but I wanted to add a keyboard listener. The problem is that the resize frames won’t correspond to the pictures.
When I click on the previous or next arrows the frame resizing works. When I use the left or rights keyboard keys the pictures move to the correct picture but the placement and frame is totally wrong. Any ideas. Thanks in advance.
<
spacing = 10;
containerMC._alpha = 0;
var pArray = new Array();
var tArray = 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];
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)-5;
nextb._x = Math.round(this._x-this._width/2)+this._width+5;
nextb._y = prevb._y=this._y-this._height/2;
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();
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++) {
tArray.push(gallery.childNodes*.attributes.title);
pArray.push(gallery.childNodes*.attributes.source);
}
//loading first picture
id = setInterval(containerMC, “loadPic”, 100, 0);
} else {
title_txt.text = “Error!”;
}
};
gallery_xml.load(“multiple_gallery.xml”);
}z
prevb.onRelease = function() {
prevImage();
};
nextb.onRelease = function() {
nextImage();
};
galleryChoice(0);
for (var i = 0; i<3; i++) {
var btn = this[“but”+i];
btn.id = i;
btn.onRelease = function() {
galleryChoice(this.id);
};
}
////////////////////////////////////////
listen = new Object();
/////////////////////////////////////
listen.onKeyDown = function()
{
if (Key.getCode() == Key.LEFT)
{
prevImage();
} else if (Key.getCode() == Key.RIGHT)
{
nextImage();
}
};
/////////////////////////////////////
Key.addListener(listen);
///////////////////////////////////////
function nextImage()
{
cur++;
if (cur>pArray.length-1)
{
containerMC.loadPic(0);
} else {
containerMC.loadPic(cur);
}
}
//////////////////////////////////////////
function prevImage()
{ cur–;
if (cur<0)
{
containerMC.loadPic(pArray.length-1);
} else {
containerMC.loadPic(cur);
}
};
/////////////////////
>