public class AudioComponent
{
// instructions to audio system
public var volume : Number = 1;
public var toPlay : Vector.<Class> = new Vector.<Class>();
public var toPlaySequence : Vector.<Vector.<Class>> = new Vector.<Vector.<Class>>();
public var toLoop : Vector.<Class> = new Vector.<Class>();
public var toStop : Vector.<Class> = new Vector.<Class>();
// used by audio system to manage the sounds that are playing
public var currentVolume : Number = 1;
public var transform : SoundTransform = new SoundTransform();
public var playing : Vector.<SoundWrapper> = new Vector.<SoundWrapper>();
public var looping : Vector.<SoundWrapper> = new Vector.<SoundWrapper>();
}
The AudioComponent class also has methods to make setting the data easier (just a play() method that adds the sound to the toPlay vector, etc. Nothing fancy). If I want to play a sound, I add it to the toPlay vector, then the AudioSystem will play it. Similarly with the toLoop, toStop and toPlaySequence vectors. Setting the volume property will cause the AudioSystem to adjust the volume of all sounds belonging to this entity.
SoundWrapper is a simple value object with the bits I may need later once a sound is playing
public class SoundWrapper
{
public var type : Class;
public var next : Vector.<Class>;
public var sound : Sound;
public var channel : SoundChannel;
}
It's not as pretty as it could be, but I've not had time to explore it further. I want to get sound into the asteroids demo so I can investigate this method a bit more and show this way to do it.
Richard
--
You received this message because you are subscribed to the Google Groups "Ash Framework" group.
Visit this group at http://groups.google.com/group/ash-framework?hl=en.