I have a page that is loading images from an XML file. There are both square buttons (button1, button2, etc) and arrow buttons (next_btn, previous_btn) to navigate through the images. Everything is working perfectly except for the fact that if a square button is pushed that is out of sequence (1-6), the next button does not recognize that and goes to the wrong image. I need the next button to recognize what the other buttons are doing and what image is currently being viewed not just the last image viewed by means of the next_btn. Here is some code so that you can see what I’m talking about:
var p = 1;
//
for (var i = 1; i <= 6; i++)
{
var button = eval(“button” + i);
button.i = i;
button.onPress = function()
{
resetAllButtons();
this._alpha = 100;
this.enabled = false;
if (loaded == filesize)
{
picture._alpha = 0;
picture.loadMovie(image[this.i - 1], 1);
desc_txt.text = description[this.i - 1];
picture_num();
}
// change the value of p
p == this.i -1 ;
};
}
// this appears outside the for() loop
listen = new Object();
listen.onKeyDown = function()
{
if (Key.getCode() == Key.LEFT)
{
prevImage();
}
else if (Key.getCode() == Key.RIGHT)
{
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function()
{
prevImage();
};
next_btn.onRelease = function()
{
nextImage();
};
//
function nextImage() {
if (p < 6) {
p++;
} else {
p = 1;
}
eval(“button” + p).onPress();
}
function prevImage() {
if (p > 1){
p–;
} else {
p = 6;
}
eval(“button” + p).onPress();
}
function resetAllButtons()
{
for (var i = 1; i <= 6; i++)
{
var button = eval(“button” + i);
button._alpha = 30;
button.enabled = true;
}
}