I’m using a scroller with the bellow code:
//scroller
function scroller():void {
import com.greensock.*;
import com.greensock.easing.*;
var yOffset:Number;
var yMin:Number = 0;
var yMax:Number = sb.track.height - sb.thumb.height;
sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);
sb.thumb.buttonMode = true;
function thumbDown(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
yOffset = mouseY - sb.thumb.y;
}
function thumbUp(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}
function thumbMove(e:MouseEvent):void {
sb.thumb.y = mouseY - yOffset;
if (sb.thumb.y <= yMin) {
sb.thumb.y = yMin;
}
if (sb.thumb.y >= yMax) {
sb.thumb.y = yMax;
}
var sp:Number = sb.thumb.y / yMax;
TweenLite.to(content.content,1, {y:(-sp*(content.content.height-content.masker.height))});
e.updateAfterEvent();
}
}
stop();
the scroller and it’s code is inside a swf that’s being loaded into the main movie.
When I unload the swf that contains the scroller, the listeners are still active to the stage and/or the scroller component.
the error I’m getting is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-1094()
How can I remove the listeners so the error does not happens? I noticed that after unloading the swf, if I click anywhere the stage, the error happens.
Thanks