ActionScript 3 Understanding the "Error 1009: Cannot access a property or method of a null object reference" Unprocessed function result


if (s.parent==this) {...}

getChildByName() is one of the many functions that can return null if an error occurred when processing its input. Therefore, if you are receiving an object from any function that can possibly return null, check for null first. Here, a property is instantly queried without first checking if s is null, this will generate the 1009 error.