From e795da0358b0ee5453961c471170e96ab10a5d48 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Sat, 20 Mar 2021 22:51:53 -0400 Subject: [PATCH] avm2: Impl `LoaderInfo.frameRate` --- .../avm2/globals/flash/display/loaderinfo.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/src/avm2/globals/flash/display/loaderinfo.rs b/core/src/avm2/globals/flash/display/loaderinfo.rs index e1ea98bab..8d60a7433 100644 --- a/core/src/avm2/globals/flash/display/loaderinfo.rs +++ b/core/src/avm2/globals/flash/display/loaderinfo.rs @@ -141,6 +141,25 @@ pub fn content_type<'gc>( Ok(Value::Undefined) } +/// `frameRate` getter +pub fn frame_rate<'gc>( + _activation: &mut Activation<'_, 'gc, '_>, + this: Option>, + _args: &[Value<'gc>], +) -> Result, Error> { + if let Some(this) = this { + if let Some(loader_stream) = this.as_loader_stream() { + match &*loader_stream { + LoaderStream::SWF(root, _) => { + return Ok(root.header().frame_rate.into()); + } + } + } + } + + Ok(Value::Undefined) +} + /// Derive `LoaderInfoObject` impls. pub fn loaderinfo_deriver<'gc>( base_proto: Object<'gc>, @@ -189,6 +208,10 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> QName::new(Namespace::public(), "contentType"), Method::from_builtin(content_type), )); + write.define_instance_trait(Trait::from_getter( + QName::new(Namespace::public(), "frameRate"), + Method::from_builtin(frame_rate), + )); class }