@@ -105,6 +105,22 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
105105 super .update (elapsedSec );
106106 }
107107
108+ public override function loadEmbedded (asset : FlxSoundAsset , ? looped : Bool , ? loopTime : Float , ? endTime : Float , autoDestroy = false , ? onComplete : Void -> Void ): FunkinSound
109+ {
110+ if (asset is String )
111+ {
112+ this ._label = asset ;
113+ }
114+ else
115+ {
116+ this ._label = ' unknown' ;
117+ }
118+
119+ super .loadEmbedded (asset , looped , loopTime , endTime , autoDestroy , onComplete );
120+
121+ return this ;
122+ }
123+
108124 public function togglePlayback (): FunkinSound
109125 {
110126 if (this .playing )
@@ -407,13 +423,18 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
407423 * @param onLoad Called when the sound finished loading. Called immediately for succesfully loaded embedded sounds.
408424 * @return A `FunkinSound` object, or `null` if the sound could not be loaded.
409425 */
410- public static function load (embeddedSound : FlxSoundAsset , volume : Float = 1.0 , looped : Bool = false , autoDestroy : Bool = false , autoPlay : Bool = false ,
411- persist : Bool = false , ? onComplete : Void -> Void , ? onLoad : Void -> Void ): Null < FunkinSound >
426+ public static function load (embeddedSound : Null < FlxSoundAsset > , volume : Float = 1.0 , looped : Bool = false , autoDestroy : Bool = false , autoPlay : Bool = false ,
427+ persist : Bool = false , ? onComplete : Void -> Void , ? onLoad : Void -> Void ): FunkinSound
412428 {
413429 var sound : FunkinSound = pool .recycle (construct );
414430
431+ // Force it to be exists so it doesn't get claimed by FlxG.sound.load or pool.
432+ sound .alive = true ;
433+ sound .exists = true ;
434+
415435 // Load the sound.
416436 // Sets `exists = true` as a side effect.
437+ @:nullSafety (Off )
417438 sound .loadEmbedded (embeddedSound , looped , autoDestroy , onComplete );
418439 FlxG .sound .defaultSoundGroup .add (sound );
419440
@@ -423,15 +444,6 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
423444 // it will get re-added (then if this was called by playMusic(), removed again)
424445 FlxG .sound .list .add (sound );
425446
426- if (embeddedSound is String )
427- {
428- sound ._label = embeddedSound ;
429- }
430- else
431- {
432- sound ._label = ' unknown' ;
433- }
434-
435447 sound .volume = volume ;
436448 sound .persist = persist ;
437449 if (autoPlay ) sound .play (true , 0 );
0 commit comments