diff --git a/core/src/avm2/globals.rs b/core/src/avm2/globals.rs index 6d394b81c..2168af6fc 100644 --- a/core/src/avm2/globals.rs +++ b/core/src/avm2/globals.rs @@ -594,6 +594,12 @@ pub fn load_player_globals<'gc>( flash::events::fullscreenevent::create_class(mc), script ); + class( + activation, + flash::events::eventphase::create_class(mc), + script, + )?; + // package `flash.utils` avm2_system_class!( bytearray, diff --git a/core/src/avm2/globals/flash/events.rs b/core/src/avm2/globals/flash/events.rs index 83b3c6d2d..a3015d4be 100644 --- a/core/src/avm2/globals/flash/events.rs +++ b/core/src/avm2/globals/flash/events.rs @@ -3,6 +3,7 @@ pub mod activityevent; pub mod event; pub mod eventdispatcher; +pub mod eventphase; pub mod fullscreenevent; pub mod ieventdispatcher; pub mod keyboardevent; diff --git a/core/src/avm2/globals/flash/events/eventphase.rs b/core/src/avm2/globals/flash/events/eventphase.rs new file mode 100644 index 000000000..139650972 --- /dev/null +++ b/core/src/avm2/globals/flash/events/eventphase.rs @@ -0,0 +1,57 @@ +//! `flash.events.EventPhase` builtin/prototype + +use crate::avm2::activation::Activation; +use crate::avm2::class::{Class, ClassAttributes}; +use crate::avm2::method::Method; +use crate::avm2::names::{Namespace, QName}; +use crate::avm2::object::Object; +use crate::avm2::value::Value; +use crate::avm2::Error; +use gc_arena::{GcCell, MutationContext}; + +/// Implements `flash.events.EventPhase`'s instance constructor. +pub fn instance_init<'gc>( + activation: &mut Activation<'_, 'gc, '_>, + this: Option>, + _args: &[Value<'gc>], +) -> Result, Error> { + if let Some(this) = this { + activation.super_init(this, &[])?; + } + + Ok(Value::Undefined) +} + +/// Implements `flash.events.EventPhase`'s class constructor. +pub fn class_init<'gc>( + _activation: &mut Activation<'_, 'gc, '_>, + _this: Option>, + _args: &[Value<'gc>], +) -> Result, Error> { + Ok(Value::Undefined) +} + +/// Construct `EventPhase`'s class. +pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> { + let class = Class::new( + QName::new(Namespace::package("flash.events"), "EventPhase"), + Some(QName::new(Namespace::public(), "Object").into()), + Method::from_builtin(instance_init, "", mc), + Method::from_builtin(class_init, "", mc), + mc, + ); + + let mut write = class.write(mc); + + write.set_attributes(ClassAttributes::SEALED); + write.set_attributes(ClassAttributes::FINAL); + + const CONSTANTS: &[(&str, u32)] = &[ + ("CAPTURING_PHASE", 1), + ("AT_TARGET", 2), + ("BUBBLING_PHASE", 3), + ]; + write.define_public_constant_uint_class_traits(CONSTANTS); + + class +}