avm2: Don't except when creating a dynamic TextField.

This commit is contained in:
David Wendt 2021-03-03 21:11:23 -05:00 committed by Mike Welsh
parent 4ef01000a8
commit 78c519cce0
2 changed files with 15 additions and 10 deletions

View File

@ -27,17 +27,13 @@ pub fn instance_init<'gc>(
if this.as_display_object().is_none() { if this.as_display_object().is_none() {
let movie = Arc::new(SwfMovie::empty(activation.context.swf.version())); let movie = Arc::new(SwfMovie::empty(activation.context.swf.version()));
let new_do = EditText::new( let movie_library = activation
&mut activation.context, .context
movie.clone(), .library
0.0, .library_for_movie_mut(movie.clone());
0.0, movie_library.force_avm_type(AvmType::Avm2);
100.0,
100.0,
);
let movie_library = activation.context.library.library_for_movie_mut(movie); let new_do = EditText::new(&mut activation.context, movie, 0.0, 0.0, 100.0, 100.0);
movie_library.check_avm_type(AvmType::Avm2).unwrap();
this.init_display_object(activation.context.gc_context, new_do.into()); this.init_display_object(activation.context.gc_context, new_do.into());
} }

View File

@ -263,6 +263,15 @@ impl<'gc> MovieLibrary<'gc> {
self.avm_type self.avm_type
} }
/// Forcibly set the AVM type of this movie.
///
/// This is intended for display object types which can be created
/// dynamically but need a placeholder movie. You should *not* attempt to
/// change the AVM type of an actual SWF.
pub fn force_avm_type(&mut self, new_type: AvmType) {
self.avm_type = new_type;
}
pub fn set_avm2_domain(&mut self, avm2_domain: Avm2Domain<'gc>) { pub fn set_avm2_domain(&mut self, avm2_domain: Avm2Domain<'gc>) {
self.avm2_domain = Some(avm2_domain); self.avm2_domain = Some(avm2_domain);
} }