This is a long time since I worked on sound on Flash. Actually the sound API itself is very good but the problem is loading. Yep, except the known issue of Sound class and sound complete event, the API itself is cool. The loading of Sound and initialising the Sound Object is not as straightforward as initialising any Display Object. For loading Display Objects I generally use a baked SWF and then load the SWF into my application container. Cast the SWF into the Display Object Class, which is the document class for the baked SWF and then access the properties and methods of it.(More about this in coming blogs). If we take the same route to load the audios from a baked SWF, it does not work!! The solution would be either attach each sound to a class and write a blank class to attach to or do not write the class and get the sound object with the utility method “getDefinitionByName()”. Both of these ways are too much of a work for a little output.
While searching for the solution I came across “bulk-loader“. Wow, it handles all kinds of load, for me, it does the trick for the audio files loading. This library provides events for each asset and dispatches event when all the assets are loaded. Cool stuff and well done “debert “, all the best to him.
While loading the assets, I will talk about sound here, but all the assets are handled the same way.While loading the assets, just add them to the bulkloader instance with an id. On all assets load complete event, move on with your application.Wherever you need to access the loaded sound, just get it with the “id” you specified previously and it will return a Sound Object.
Happy Flashing 🙂