createjssoundjspreloadjs

Is there a `unload` item for Createjs' preloadjs/soundjs


Once you've loaded a mp3 into a sound object via createjs, how dow you destroy & clear it from memory?


Solution

  • There are static methods for this:

    1. removeSound: Remove stored references to sounds by source
    2. removeSounds: Remove multiple sound src's
    3. removeAllSounds: Wipe references to sounds

    Examples

     createjs.Sound.removeSound("myID");
     createjs.Sound.removeSound("myAudioBasePath/mySound.ogg");
     createjs.Sound.removeSound("myPath/myOtherSound.mp3", "myBasePath/");
     createjs.Sound.removeSound({mp3:"musicNoExtension", ogg:"music.ogg"}, "myBasePath/");
    

    Check out the docs for more info.

    This is not a super common use-case, so if you run into issue, please feel free to open an issue on GitHub