@@ -4,10 +4,10 @@ use crate::{
4
4
buffer:: Substream ,
5
5
context:: UpdateContext ,
6
6
display_object:: { self , DisplayObject , MovieClip , TDisplayObject } ,
7
+ string:: AvmString ,
7
8
} ;
8
9
use downcast_rs:: Downcast ;
9
10
use gc_arena:: Collect ;
10
- use ruffle_macros:: istr;
11
11
use slotmap:: { new_key_type, Key , SlotMap } ;
12
12
13
13
#[ cfg( feature = "audio" ) ]
@@ -380,14 +380,13 @@ impl<'gc> AudioManager<'gc> {
380
380
381
381
/// Update state of active sounds. Should be called once per frame.
382
382
pub fn update_sounds ( context : & mut UpdateContext < ' gc > ) {
383
+ let mc = context. gc ( ) ;
384
+
383
385
// We can't use 'context' to construct an event inside the
384
386
// 'retain()' closure, so we queue the events up here, and fire
385
387
// them after running 'retain()'
386
388
let mut event_targets = Vec :: new ( ) ;
387
389
388
- // We need to declare this up here to avoid borrow-checker issues
389
- let on_sound_complete_string = istr ! ( context, "onSoundComplete" ) ;
390
-
391
390
// Update the position of sounds, and remove any completed sounds.
392
391
context. audio_manager . sounds . retain ( |sound| {
393
392
if let Some ( pos) = context. audio . get_sound_position ( sound. instance ) {
@@ -413,11 +412,13 @@ impl<'gc> AudioManager<'gc> {
413
412
414
413
// Fire soundComplete event.
415
414
if let Some ( root) = context. stage . root_clip ( ) {
415
+ let method_name = AvmString :: new_utf8 ( mc, "onSoundComplete" ) ;
416
+
416
417
context. action_queue . queue_action (
417
418
root,
418
419
crate :: context:: ActionType :: Method {
419
420
object,
420
- name : on_sound_complete_string ,
421
+ name : method_name ,
421
422
args : vec ! [ ] ,
422
423
} ,
423
424
false ,
0 commit comments