avm2: Impl `LoaderInfo.frameRate`
This commit is contained in:
parent
cbd167fd6c
commit
e795da0358
|
@ -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<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.
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue