core: Allow pulling the AVM2 Object out of a participating movie clip.

This commit is contained in:
David Wendt 2020-08-05 20:23:47 -04:00 committed by Mike Welsh
parent f85319aa4c
commit edd31c4b83
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
//! `MovieClip` display object and support code. //! `MovieClip` display object and support code.
use crate::avm1::{Avm1, Object as Avm1Object, StageObject, TObject, Value as Avm1Value}; use crate::avm1::{Avm1, Object as Avm1Object, StageObject, TObject, Value as Avm1Value};
use crate::avm2::Value as Avm2Value;
use crate::backend::audio::AudioStreamHandle; use crate::backend::audio::AudioStreamHandle;
use crate::avm1::activation::{Activation, ActivationIdentifier}; use crate::avm1::activation::{Activation, ActivationIdentifier};
@ -1276,6 +1277,15 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
.unwrap_or(Avm1Value::Undefined) .unwrap_or(Avm1Value::Undefined)
} }
fn object2(&self) -> Avm2Value<'gc> {
self.0
.read()
.object
.and_then(|o| o.as_avm2_object().ok())
.map(Avm2Value::from)
.unwrap_or(Avm2Value::Undefined)
}
fn unload(&self, context: &mut UpdateContext<'_, 'gc, '_>) { fn unload(&self, context: &mut UpdateContext<'_, 'gc, '_>) {
for child in self.children() { for child in self.children() {
child.unload(context); child.unload(context);