Listener question if on frame x then do this

hey i am trying to write a function that works with the xml slideshow on kirupa. i want buttion to be visible or not visible based on the listening to what frame/image the slider is on.

I will not change when the image changes but the code is:

addListener§;
if (p = 0){
red1._visible = 1;
red2._visible = 0;
red3._visible = 0;
red4._visible = 0;
};
if (p = 1){
red1._visible = 0;
red2._visible = 1;
red3._visible = 0;
red4._visible = 0;
};
if (p = 2){
red1._visible = 0;
red2._visible = 0;
red3._visible = 1;
red4._visible = 0;
};
if (p = 3){
red1._visible = 0;
red2._visible = 0;
red3._visible = 0;
red4._visible = 1;
};

p is the frame number same variable as in the tutorial.

thanks again

miles