Component Listeners

I have two components in my movie, I’m not sure how to write out the code for the listeners. Is it possible to write one listener that listens for changes in both components or do I have to write a separate listener for each? How would this look like written out?

You can write one listener for both components. Example:


listen = new Object(); //create the listener
listen.change = function(evt) { //evt is the object holding a reference to the object calling the event
    if(evt.target == component1) { //evt.target is a reference to the object calling the change function
         //do actions for component1
    } else if(evt.target == component2) {
        //do actions for component2
    }
}
component1.addEventListener("change", listen);
component2.addEventListener("change", listen);

Hope this helps :cap: