error 1009 ScrollPane/endDrag() null fix
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: error 1009 ScrollPane/endDrag() null fix

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    17

    error 1009 ScrollPane/endDrag() null fix

    I have a scrollPane that I am removing from the stage that has scrollDrag = true. When its removed however I get this error when clicking on other objects and the stage.



    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at fl.containers::ScrollPane/endDrag()



    anyone know a fix for this?

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,513
    Seems to be a known bug, the best solution seems to be to create a subclass of ScrollPane, and just override endDrag.
    Code:
    package {
    	import fl.containers.*;
    	import flash.events.*;
    	public class ScrollPain extends ScrollPane {
    		protected override function endDrag(event:MouseEvent):void {
    			if (stage) {
    				stage.removeEventListener(MouseEvent.MOUSE_MOVE, doDrag);
    			}
    		}
    	}
    }

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    17
    im not familiar with creating sub classes, how do I set that up?

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,513
    Easiest way for this...
    Place code above in file 'ScrollPain.as', and place in same folder as your fla.
    In the fla, in the library, right click on ScrollPane item, and select properties.
    Under the Linkage, change the Class to 'ScrollPain'. Click OK.


    Note: spelling and case are important.

  5. #5
    Junior Member
    Join Date
    Oct 2009
    Posts
    17
    thats what I thought, if I do that tho the package for scrollPain references the .fla.containers and I get an error compiling for that saying that those imports dont exist at that location. Which they dont of course cuz their in a different folder. Do I just change the import locations for those files in the scrollPain.as?

  6. #6
    :
    Join Date
    Dec 2002
    Posts
    3,513
    Sure, give it a try...

  7. #7
    Junior Member
    Join Date
    Oct 2009
    Posts
    17
    ok instead of doing that I just put the scrollPain.as in the fl.containers and referenced that in my linkage, however now I get

    TypeError: Error #1006: setStyle is not a function.
    at home1_fla::MainTimeline/frame2()

    because I have to set the style in the code to use a gradient mask over the text im scrolling inside the scrollpane

  8. #8
    Registered User
    Join Date
    Jan 2013
    Posts
    1
    Quote Originally Posted by dawsonk View Post
    Seems to be a known bug, the best solution seems to be to create a subclass of ScrollPane, and just override endDrag.
    Code:
    package {
    	import fl.containers.*;
    	import flash.events.*;
    	public class ScrollPain extends ScrollPane {
    		protected override function endDrag(event:MouseEvent):void {
    			if (stage) {
    				stage.removeEventListener(MouseEvent.MOUSE_MOVE, doDrag);
    			}
    		}
    	}
    }
    You saved me at least a few hours of breaking my head over this stupid bug. I created an account just to thank you for this solution. Thank you and keep on rocking.

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

Poll by Flashkit.com