From 41ad7567923708d25d246e4c33144325a3e3ccd4 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Wed, 10 Feb 2021 21:41:28 -0500 Subject: [PATCH] avm2: Implement `Graphics.endFill` --- .../avm2/globals/flash/display/graphics.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/src/avm2/globals/flash/display/graphics.rs b/core/src/avm2/globals/flash/display/graphics.rs index 2a6799729..384e0347b 100644 --- a/core/src/avm2/globals/flash/display/graphics.rs +++ b/core/src/avm2/globals/flash/display/graphics.rs @@ -127,6 +127,23 @@ pub fn curve_to<'gc>( Ok(Value::Undefined) } +/// Implements `Graphics.endFill`. +pub fn end_fill<'gc>( + activation: &mut Activation<'_, 'gc, '_>, + this: Option>, + _args: &[Value<'gc>], +) -> Result, Error> { + if let Some(this) = this { + if let Some(dobj) = this.as_display_object() { + if let Some(mc) = dobj.as_movie_clip() { + mc.set_fill_style(&mut activation.context, None); + } + } + } + + Ok(Value::Undefined) +} + /// Construct `Graphics`'s class. pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> { let class = Class::new( @@ -151,6 +168,10 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> QName::new(Namespace::public(), "curveTo"), Method::from_builtin(curve_to), )); + write.define_instance_trait(Trait::from_method( + QName::new(Namespace::public(), "endFill"), + Method::from_builtin(end_fill), + )); class }