PDA

View Full Version : removeDammitListener


boomshanka
05-28-2008, 11:09 PM
Hi,

i'm trying to remove an Event Listener that is inside another function . Is this possible ?

graph1.addEventListener(MouseEvent.MOUSE_DOWN, bar1drag);
graph1.addEventListener(MouseEvent.MOUSE_UP, bar1drop);

function bar1drag(event:MouseEvent):void

{
graph1.addEventListener(Event.ENTER_FRAME, bar1go);
function bar1go(event:Event):void
{
var currentY:Number = mouseY;
event.target.height = (currentY * -1) + 174.5;
}
}


function bar1drop(event:MouseEvent):void

{
graph1.removeEventListener(Event.ENTER_FRAME, bar1go);
// This is where it dies - doesn't recognise 'bar1go'
}

senocular
05-29-2008, 01:21 AM
Don't nest functions. Define bar1go out with the other functions and it should work

boomshanka
05-29-2008, 01:32 AM
Wicked ... thanks heaps :1