avm2: Manually-constructed movie clips (and their subclasses) should be accessible from the display object tree.
This commit is contained in:
parent
63af38be9a
commit
4521c2b599
|
@ -26,8 +26,19 @@ pub fn instance_init<'gc>(
|
|||
activation.super_init(this, &[])?;
|
||||
|
||||
if this.as_display_object().is_none() {
|
||||
let mut proto = this
|
||||
.proto()
|
||||
.ok_or("Attempted to construct bare-object MovieClip")?;
|
||||
let constr = proto
|
||||
.get_property(proto, &QName::dynamic_name("constructor"), activation)?
|
||||
.coerce_to_object(activation)?;
|
||||
let movie = Arc::new(SwfMovie::empty(activation.context.swf.version()));
|
||||
let new_do = MovieClip::new(SwfSlice::empty(movie), activation.context.gc_context);
|
||||
let new_do = MovieClip::new_with_avm2(
|
||||
SwfSlice::empty(movie),
|
||||
this,
|
||||
constr,
|
||||
activation.context.gc_context,
|
||||
);
|
||||
|
||||
this.init_display_object(activation.context.gc_context, new_do.into());
|
||||
}
|
||||
|
|
|
@ -97,6 +97,35 @@ impl<'gc> MovieClip<'gc> {
|
|||
))
|
||||
}
|
||||
|
||||
pub fn new_with_avm2(
|
||||
swf: SwfSlice,
|
||||
this: Avm2Object<'gc>,
|
||||
constr: Avm2Object<'gc>,
|
||||
gc_context: MutationContext<'gc, '_>,
|
||||
) -> Self {
|
||||
MovieClip(GcCell::allocate(
|
||||
gc_context,
|
||||
MovieClipData {
|
||||
base: Default::default(),
|
||||
static_data: Gc::allocate(gc_context, MovieClipStatic::empty(swf)),
|
||||
tag_stream_pos: 0,
|
||||
current_frame: 0,
|
||||
audio_stream: None,
|
||||
container: ChildContainer::new(),
|
||||
object: Some(this.into()),
|
||||
clip_actions: Vec::new(),
|
||||
frame_scripts: Vec::new(),
|
||||
has_button_clip_event: false,
|
||||
flags: EnumSet::empty(),
|
||||
avm2_constructor: Some(constr),
|
||||
drawing: Drawing::new(),
|
||||
is_focusable: false,
|
||||
has_focus: false,
|
||||
enabled: true,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
pub fn new_with_data(
|
||||
gc_context: MutationContext<'gc, '_>,
|
||||
id: CharacterId,
|
||||
|
|
Loading…
Reference in New Issue