Skip to content

Commit

Permalink
avm2: Use NativeCallable in Stage3D code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Jan 22, 2025
1 parent 26ccd85 commit de61d87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
20 changes: 9 additions & 11 deletions core/src/avm2/globals/flash/display/stage_3d.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use ruffle_render::backend::Context3DProfile;

use crate::avm2::object::Context3DObject;
use crate::avm2::object::TObject;

use crate::avm2::globals::methods::flash_events_event_dispatcher as event_dispatcher_methods;
use crate::avm2::object::{Context3DObject, EventObject, TObject};
use crate::avm2::parameters::ParametersExt;
use crate::avm2::{Activation, Error, Value};
use ruffle_render::backend::Context3DProfile;

pub use crate::avm2::object::stage_3d_allocator;

Expand Down Expand Up @@ -62,13 +60,13 @@ pub fn request_context3d_internal<'gc>(
let context3d_obj = Context3DObject::from_context(activation, context, this_stage3d)?;
this_stage3d.set_context3d(Some(context3d_obj), activation.gc());

let event = activation
.avm2()
.classes()
.event
.construct(activation, &["context3DCreate".into()])?;
let event = EventObject::bare_default_event(activation.context, "context3DCreate");

this.call_public_property("dispatchEvent", &[event], activation)?;
this.call_method(
event_dispatcher_methods::DISPATCH_EVENT,
&[event.into()],
activation,
)?;
}

Ok(Value::Undefined)
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/globals/flash/events/EventDispatcher.as
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ package flash.events {
public native function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void;
public native function hasEventListener(type:String):Boolean;

[Ruffle(NativeCallable)]
public function dispatchEvent(event:Event):Boolean {
// Some SWFs rely on the getter for `target` being called
if (event.target) {
Expand Down

0 comments on commit de61d87

Please sign in to comment.