It drives me crazy. Why does removeEventListeners not work?
Class constructor
public function item(brand:String, title:String, price:Number, mp:Number, path:String, sb1:*, sb2:*):void
sb1: * and sb2: * are object hooks.
These are designated listeners:
_sb1.addEventListener("Changed", slideBarChanged); // Price _sb2.addEventListener("Changed", slideBarChanged); // MegaPixels
This function is called:
private function slideBarChanged(e:Event):void { switch(e.target.type) { case "Price": if(int(e.target.currVal) > Math.abs(this.price)) { this._active = false; _sb2.removeEventListener("Changed", slideBarChanged); } else { this._active = true; _sb2.addEventListener("Changed", slideBarChanged); } break; case "MegaPixels": if(int(e.target.currVal) > Math.abs(this.mpixels)) { this._active = false; _sb1.removeEventListener("Changed", slideBarChanged); } else { this._active = true; _sb1.addEventListener("Changed", slideBarChanged); } break; }
Everthing works, but the listener is not deleted when the element goes _active = false; Effectively this should work as follows:
If the price is too high, then ignore the megapixels and listen only to the price. If megapixels are too high, then ignore the price and listen only to megapixels.
Violation of my brain, any help is greatly appreciated. Thanx.
Steve source share