avm2: Impl `LoaderInfo.frameRate`

This commit is contained in:
David Wendt 2021-03-20 22:51:53 -04:00 committed by kmeisthax
parent cbd167fd6c
commit e795da0358
1 changed files with 23 additions and 0 deletions

View File

@ -141,6 +141,25 @@ pub fn content_type<'gc>(
Ok(Value::Undefined) Ok(Value::Undefined)
} }
/// `frameRate` getter
pub fn frame_rate<'gc>(
_activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, 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. /// Derive `LoaderInfoObject` impls.
pub fn loaderinfo_deriver<'gc>( pub fn loaderinfo_deriver<'gc>(
base_proto: Object<'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"), QName::new(Namespace::public(), "contentType"),
Method::from_builtin(content_type), Method::from_builtin(content_type),
)); ));
write.define_instance_trait(Trait::from_getter(
QName::new(Namespace::public(), "frameRate"),
Method::from_builtin(frame_rate),
));
class class
} }