Proportional Image Scaling Help

I have been following the instructions posted here on how to achieve proportional image scaling:

http://blog.fryewiles.com/design/07-14-2008/proportional-image-scaling-in-full-browser-flash

I want to have one image background for one frame, and then another image background on another frame… so when the viewer goes to different parts of the site the scalable background image changes.

I copy and pasted the AS3 code into the actions section for the frame:

//set stage for FBF
//set stage for FBF
stage.align = “TL”;
stage.scaleMode = “noScale”;
//define dynamic aspect ratios
var picHeight = pic.height / pic.width;
var picWidth = pic.width / pic.height;
//add event listener to the stage
stage.addEventListener(Event.RESIZE, sizeListener);
//conditional statement to account for various initial browswer sizes and proportions
function scaleProportional():void {
if ((stage.stageHeight / stage.stageWidth) < picHeight) {
pic.width = stage.stageWidth;
pic.height = picHeight * pic.width;
} else {
pic.height = stage.stageHeight;
pic.width = picWidth * pic.height;
};
}
//center picture on stage
function centerPic():void {
pic.x = stage.stageWidth / 2;
pic.y = stage.stageHeight / 2;
}
// make listener change picture size and center picture on browser resize
function sizeListener(e:Event):void {
scaleProportional();
centerPic();
}
//run initial locations and size
scaleProportional();
centerPic();

It gave me a duplicate function error. So I changed all the variables ‘pic’ to something else… for example, ‘pic1’. Still didn’t work. Then I changed ‘sizeListener’ to ‘sizeListener1’, still didn’t work. Then I changed ‘scaleProportional’ to ‘scaleProportional1’ and it kind of worked, but keeps giving me the error that ‘scaleProportional1’ but still keeps giving me errors.

Can someone please provide me with instructions on how I can implement multiple instances of this scalable background script on multiple pictures without conflicts? Thanks for your patience.