Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
public function removeObserver( notificationName:String, notifyContext:Object ):void { // the observer list for the notification under inspection var observers:Array = observerMap[ notificationName ] as Array; // find the observer for the notifyContext for ( var i:int=0; i<observers.length; i++ ) { if ( Observer(observers[i]).compareNotifyContext( notifyContext ) == true ) { // there can only be one Observer for a given notifyContext // in any given Observer list, so remove it and break observers.splice(i,1); break; } } // Also, when a Notification's Observer list length falls to // zero, delete the notification key from the observer map if ( observers.length == 0 ) { delete observerMap[ notificationName ]; } }
var observers:Array = observerMap[ notificationName ] as Array;
if(!observers) return;