Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
public function notifyObservers( notification:INotification ) : void{ if( observerMap[ notification.getName() ] != null ) { // Get a reference to the observers list for this notification name var observers_ref:Array = observerMap[ notification.getName() ] as Array; // Copy observers from reference array to working array, // since the reference array may change during the notification loop var observers:Array = new Array(); var observer:IObserver; for (var i:Number = 0; i < observers_ref.length; i++) { observer = observers_ref[ i ] as IObserver; observers.push( observer ); } // Notify Observers from the working array for (i = 0; i < observers.length; i++) { observer = observers[ i ] as IObserver; observer.notifyObserver( notification ); } }}
public function notifyObservers( notification:INotification ) : void{ var observers_ref:Array = observerMap[ notification.getName() ] as Array; if( observers_ref != null ) { // Copy observers from reference array to working array, // since the reference array may change during the notification loop var observers:Array = observers_ref.slice(0); // Notify Observers from the working array for( var i:uint = 0; i<observers.length; i++) { observer = observers[ i ] as IObserver; observer.notifyObserver( notification ); } }}