avm1: Call the respective listeners
This commit is contained in:
parent
795cd72dce
commit
a14f19e9e5
|
@ -344,6 +344,8 @@ impl<'gc> Avm1<'gc> {
|
||||||
method: &str,
|
method: &str,
|
||||||
args: &[Value<'gc>],
|
args: &[Value<'gc>],
|
||||||
) {
|
) {
|
||||||
|
let global = self.global_object(context);
|
||||||
|
|
||||||
let mut activation = Activation::from_nothing(
|
let mut activation = Activation::from_nothing(
|
||||||
self,
|
self,
|
||||||
ActivationIdentifier::root("[System Listeners]"),
|
ActivationIdentifier::root("[System Listeners]"),
|
||||||
|
@ -353,7 +355,9 @@ impl<'gc> Avm1<'gc> {
|
||||||
active_clip,
|
active_clip,
|
||||||
);
|
);
|
||||||
|
|
||||||
avm_warn!(activation, "{} - {}", broadcaster, method);
|
let broadcaster = global.coerce_to_object(&mut activation, context).get(broadcaster, &mut activation, context).unwrap().coerce_to_object(&mut activation, context);
|
||||||
|
|
||||||
|
let _ = as_broadcaster::broadcast_internal(&mut activation, context, broadcaster, args, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Halts the AVM, preventing execution of any further actions.
|
/// Halts the AVM, preventing execution of any further actions.
|
||||||
|
|
|
@ -113,6 +113,16 @@ pub fn broadcast_message<'gc>(
|
||||||
let event_name = event_name_value.coerce_to_string(activation, context)?;
|
let event_name = event_name_value.coerce_to_string(activation, context)?;
|
||||||
let call_args = &args[1..];
|
let call_args = &args[1..];
|
||||||
|
|
||||||
|
broadcast_internal(activation, context, this, call_args, &event_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn broadcast_internal<'gc>(
|
||||||
|
activation: &mut Activation<'_, 'gc>,
|
||||||
|
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||||
|
this: Object<'gc>,
|
||||||
|
call_args: &[Value<'gc>],
|
||||||
|
method_name: &str
|
||||||
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
let listeners = this.get("_listeners", activation, context)?;
|
let listeners = this.get("_listeners", activation, context)?;
|
||||||
|
|
||||||
if let Value::Object(listeners) = listeners {
|
if let Value::Object(listeners) = listeners {
|
||||||
|
@ -120,7 +130,7 @@ pub fn broadcast_message<'gc>(
|
||||||
let listener = listeners.array_element(i);
|
let listener = listeners.array_element(i);
|
||||||
|
|
||||||
if let Value::Object(listener) = listener {
|
if let Value::Object(listener) = listener {
|
||||||
listener.call_method(&event_name, call_args, activation, context)?;
|
listener.call_method(method_name, call_args, activation, context)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
//MovieClipLoader.addListener == asbroadcaster.addListener
|
|
||||||
true
|
|
||||||
//Stage.addListener == asbroadcaster.addListener
|
//Stage.addListener == asbroadcaster.addListener
|
||||||
true
|
true
|
||||||
//System.IME.addListener == asbroadcaster.addListener
|
//System.IME.addListener == asbroadcaster.addListener
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue