-
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?
-
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);
}
}
}
}
-
im not familiar with creating sub classes, how do I set that up?
-
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.
-
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?
-
-
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
-
Originally Posted by dawsonk
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|