Re: [Flashcoders] Catching an error from a component
> > > Before you try this code I would urge you to check the setup of your > application as it (usually) should be avoidable to have this error in the > first place. > > > Greetz Erik Thanks for your comments Erik, my set up is as follows ScriptHolder <- scroll component inside scriptHolder The script holder has an event to detect the mouse position, if the mouse position is out of the area where the scroll component is located at then the scroll component is "destroyed"... everything works fine but say you press the down or up arrow key, then you hold the mouse down and roll off the component the "destroy" method then is fired because you are located away from the component and that is how the error fires... You are right in regards to having to check my setup specially since it was one of those "we need it done now, no matter what has to be done" times. Thanks again, Helmut On 1/29/08, Helmut Granda <[EMAIL PROTECTED]> wrote: > > > > I have a scroll component that sometimes is deleted from the display > list > > while the user is holding the scroll bar and I get this error: > > > > TypeError: Error #1009: Cannot access a property or method of a null > > object > > reference. > > at fl.controls::ScrollBar/fl.controls:ScrollBar::thumbReleaseHandler > () > > > > We know this error is fired since the scroll component is non-existent > by > > the time the user releases the scroll bar...I am trying to catch it but > > not > > sure how should I catch this type of error since this is fired from > within > > the component... > > > > I have tried the following: > > > > sp.addEventListener(MouseEvent.MOUSE_UP, catchError); > > sp.addEventListener(MouseEvent.MOUSE_LEAVE, catchError); > > > > and so forth... I am still trying but some suggestions would be great. > > > > Thanks, > > Helmut > > _ > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Catching an error from a component
I am not sure how it is possible that the item has been removed from the display list. I however take your word for it :) Since you can not put a try / catch block (or check) around error area the solutions are limited. My first thought was to extend the component and override the thumbReleaseHandler, this method is however most likely private and thus can not be overridden. You could however try this: scrollbar.addEventListener(MouseEvent.MOUSE_UP, _listener, false, 1); function _listener(e:MouseEvent):void { //check if the scrollbar is part of the display list if (!scrollbar.stage) { //It is not in the display list, stop the event from being dispatched to the default dispatcher e.stopImmediatePropagation(); }; }; In the above code you add a listener that has a higher priority than the internal listener of the scrollbar. Within the listener you check if the scrollbar has still has a stage reference (which means it is still part of the display list). If it has not, you tell the event dispatcher to stop dispatching the event. Before you try this code I would urge you to check the setup of your application as it (usually) should be avoidable to have this error in the first place. Greetz Erik On 1/29/08, Helmut Granda <[EMAIL PROTECTED]> wrote: > > I have a scroll component that sometimes is deleted from the display list > while the user is holding the scroll bar and I get this error: > > TypeError: Error #1009: Cannot access a property or method of a null > object > reference. > at fl.controls::ScrollBar/fl.controls:ScrollBar::thumbReleaseHandler() > > We know this error is fired since the scroll component is non-existent by > the time the user releases the scroll bar...I am trying to catch it but > not > sure how should I catch this type of error since this is fired from within > the component... > > I have tried the following: > > sp.addEventListener(MouseEvent.MOUSE_UP, catchError); > sp.addEventListener(MouseEvent.MOUSE_LEAVE, catchError); > > and so forth... I am still trying but some suggestions would be great. > > Thanks, > Helmut > _ > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Catching an error from a component
I have a scroll component that sometimes is deleted from the display list while the user is holding the scroll bar and I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at fl.controls::ScrollBar/fl.controls:ScrollBar::thumbReleaseHandler() We know this error is fired since the scroll component is non-existent by the time the user releases the scroll bar...I am trying to catch it but not sure how should I catch this type of error since this is fired from within the component... I have tried the following: sp.addEventListener(MouseEvent.MOUSE_UP, catchError); sp.addEventListener(MouseEvent.MOUSE_LEAVE, catchError); and so forth... I am still trying but some suggestions would be great. Thanks, Helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders