I am new Flash and Actionscript. This is actually my first attempt at creating a website with it.
I have a mc that has 23 buttons (thumbnails) on it, and one larger picture(uiloader) in the middle. When you click on a button, it changes the source value of the uiloader to be equal to the file that the button is associated with, and changes a dynamic textfield below the picture to a description string.
It is my understanding that I need 23 event listeners, one for each button and then 23 event handlers, one for each event listener. This seems crazy to me. I have created it that way, and it works just fine, but what if I had 200 buttons, would I have to create 200 event handlers?
Is there a way to do something like the following:
function onPhotoClick(evt:MouseEvent,file:String,desc:String):void {
Photo_ldr.source = file;
Photo_txt.text = desc;
}
Photo1_btn.addEventListener(MouseEvent.CLICK,onPhotoClick("photo1.jpg","photo1 description");
Photo2_btn.addEventListener(MouseEvent.CLICK,onPhotoClick("photo2.jpg","photo2 description");
I know this does not work, but any suggestions, I am sure others are doing something like this. Also, I looked into creating cutom events, but then wouldnt I need to create 23 custom events, one for each button, and then still have the 23 event listeners.
Anyone have know of a simple flash that includes source to do something like this?
Thanks,
Jim