avm1: Adjust precedence of children in StageObject::get

Children instances should shadow display object magic properties.
For example, a child named "_x" will be returned instead of the
parent's _x position in GetMember.
This commit is contained in:
Mike Welsh 2021-04-15 12:21:41 -07:00
parent 9224e85a2d
commit 34886933e5
1 changed files with 10 additions and 10 deletions

View File

@ -140,10 +140,12 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
if self.has_own_property(activation, name) { if self.has_own_property(activation, name) {
// 1) Actual properties on the underlying object // 1) Actual properties on the underlying object
self.get_local(name, activation, (*self).into()) self.get_local(name, activation, (*self).into())
} else if let Some(property) = props.read().get_by_name(&name) { } else if let Some(level) =
// 2) Display object properties such as _x, _y obj.display_object
let val = property.get(activation, obj.display_object)?; .get_level_by_path(name, &mut activation.context, case_sensitive)
Ok(val) {
// 2) _levelN
Ok(level.object())
} else if let Some(child) = obj } else if let Some(child) = obj
.display_object .display_object
.as_container() .as_container()
@ -151,12 +153,10 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
{ {
// 3) Child display objects with the given instance name // 3) Child display objects with the given instance name
Ok(child.object()) Ok(child.object())
} else if let Some(level) = } else if let Some(property) = props.read().get_by_name(&name) {
obj.display_object // 4) Display object properties such as _x, _y
.get_level_by_path(name, &mut activation.context, case_sensitive) let val = property.get(activation, obj.display_object)?;
{ Ok(val)
// 4) _levelN
Ok(level.object())
} else { } else {
// 5) Prototype // 5) Prototype
Ok(search_prototype(self.proto(), name, activation, (*self).into())?.0) Ok(search_prototype(self.proto(), name, activation, (*self).into())?.0)