PDA

View Full Version : Hide errors



noobie123
December 21st, 2009, 11:29 PM
Is there a way to suppress errors from appearing in a pop up box when the swf is viewed in a browser?

I get the following run-time-error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at CopyofDivRemedialCopy4_fla::MainTimeline/hintAns()
at CopyofDivRemedialCopy4_fla::MainTimeline/checkMult()

I have a requirement to call different functions on a button click at different times. But I have taken care to remove the first event listener before I add a second one. What could be going wrong?

The rest of the program runs fine even with this error. Is there some way to hide it?

sekasi
December 21st, 2009, 11:36 PM
try/catch will hide it, but it's a bad way of hiding faulty code. faulty code is always bad ;)

McGuffin
December 21st, 2009, 11:39 PM
You're calling parent.removeChild(child) when child isn't a child of parent. You can do two things:



// suppresses the error, doesn't fix it
try {
parent.removeChild(child);
} catch (e:Error) {}




// stops error from occurring
if (parent.contains(child)) {
parent.removeChild(child);
}