A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Scrollbar problem--using gotoandlearn oop scroll

Threaded View

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    75

    Scrollbar problem--using gotoandlearn oop scroll

    im using the object oriented scroll bar from gotoandlearn.com,
    I am having issues. I think I need to remove the thumbUp listener from the stage but I dont know where. Just to let you know scrollbar is in a movieclip called scrollBox, I followed the setup just as lee did in the tutorial. However I get this error when navigating to different frame labels and than navigating back to the page with the scroll bar in it. I think the problem is that thumbUp is still listening and than everytime you go back to the page its called again and again....any suggestions

    I keep getting these errors:TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at ui::ScrollBar/thumbUp()
    The how_to button was clicked
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at ui::ScrollBar/thumbUp()
    The contact button was clicked
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at ui::ScrollBar/thumbUp()
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at ui::ScrollBar/thumbUp()


    my code is:

    Code:
    ackage ui
    {
    	import flash.display.*;
    	import flash.events.*;
    	
    	public class ScrollBar extends MovieClip
    	{
    		private var yOffset:Number;
    		private var yMin:Number;
    		private var yMax:Number;
    		
    		public function ScrollBar():void
    		{
    			yMin = 0;
    			yMax = track.height - thumb.height;
    			thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
    			stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);
    		}
    		
    		private function thumbDown(e:MouseEvent):void
    		{
    			stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
    			yOffset = mouseY - thumb.y;
    		}
    
    		private function thumbUp(e:MouseEvent):void
    		{
    			stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
    		}
    
    		private function thumbMove(e:MouseEvent):void
    		{
    			thumb.y = mouseY - yOffset;
    			if(thumb.y <= yMin)
    				thumb.y = yMin;
    			if(thumb.y >= yMax)
    				thumb.y = yMax;
    			dispatchEvent(new ScrollBarEvent(thumb.y / yMax));
    			e.updateAfterEvent();
    		}
    	}
    }
    Last edited by cleantable; 11-22-2009 at 12:23 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center