Move `_global` and `_root` to the MovieClip object, and implement `_parent` while we're in here.
This commit is contained in:
parent
d35e36def5
commit
0f04d97002
|
@ -1017,15 +1017,6 @@ impl<'gc> Avm1<'gc> {
|
|||
let var_path = self.pop()?;
|
||||
let path = var_path.as_string()?;
|
||||
|
||||
// Special hardcoded variables
|
||||
if path == "_root" {
|
||||
self.push(self.root_object(context));
|
||||
return Ok(());
|
||||
} else if path == "_global" {
|
||||
self.push(self.global_object(context));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let is_slashpath = Self::variable_name_is_slash_path(path);
|
||||
let mut result = None;
|
||||
if is_slashpath {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::avm1::object::{Attribute::*, Object};
|
||||
use crate::avm1::Value;
|
||||
use crate::movie_clip::MovieClip;
|
||||
use enumset::EnumSet;
|
||||
use gc_arena::MutationContext;
|
||||
|
||||
macro_rules! with_movie_clip {
|
||||
|
@ -80,5 +81,33 @@ pub fn create_movie_object<'gc>(gc_context: MutationContext<'gc, '_>) -> Object<
|
|||
}
|
||||
);
|
||||
|
||||
object.force_set_virtual(
|
||||
"_global",
|
||||
|avm, context, _this, _args| avm.global_object(context),
|
||||
None,
|
||||
EnumSet::new(),
|
||||
);
|
||||
|
||||
object.force_set_virtual(
|
||||
"_root",
|
||||
|avm, context, _this, _args| avm.root_object(context),
|
||||
None,
|
||||
EnumSet::new(),
|
||||
);
|
||||
|
||||
object.force_set_virtual(
|
||||
"_parent",
|
||||
|_avm, _context, this, _args| {
|
||||
this.read()
|
||||
.display_node()
|
||||
.and_then(|mc| mc.read().parent())
|
||||
.and_then(|dn| dn.read().object().as_object().ok())
|
||||
.map(|o| Value::Object(o.to_owned()))
|
||||
.unwrap_or(Value::Undefined)
|
||||
},
|
||||
None,
|
||||
EnumSet::new(),
|
||||
);
|
||||
|
||||
object
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue