// Richard Caceres, rcaceres {at} ucla.edu // DMA 199 // $Id: HelloHarmony.as,v 381.1 2008-02-07 01:06:55-08 - - $ // $Date: 2008-02-07 01:06:55-08 $ package { import flash.display.Sprite; import flash.events.*; import flash.media.Sound; import flash.media.SoundChannel; import flash.net.URLRequest; public class HelloHarmony extends Sprite { private var urls:Array; private var boxsprites:Array; private var song:SoundChannel; private var curr_sound_index = 0; private var boxspr:Sprite; private var sounds:Array; //////////////////////////////////////////////////////////////////// public function HelloHarmony () { // instantiate all these sounds which are embeded above sounds = [ new mbira01() as Sound, new mbira02() as Sound, new mbira03() as Sound, new mbira04() as Sound, new mbira05() as Sound, new mbira06() as Sound, new mbira07() as Sound, new mbira08() as Sound, new mbira09() as Sound, new mbira10() as Sound, new mbira11() as Sound ]; // create a sprite for each url boxsprites = new Array(); for (var i = 0; i < sounds.length; i++){ var tmpspri = new BoxSprite(sounds[i]); tmpspri.x = 10 + i * 40; tmpspri.y = 10; boxsprites.push (tmpspri); addChild (tmpspri); } addEventListener (Event.ENTER_FRAME, update); //loadAndPlayNewSound (urls[curr_sound_index]); } //////////////////////////////////////////////////////////////////// public function update(e:Event):void { for (var i=0; i < sounds.length; i++) { boxsprites[i].update(); } // call draw_ after update draw_(); } //////////////////////////////////////////////////////////////////// public function draw_():void { for (var i=0; i < sounds.length; i++) { boxsprites[i].draw_(); } } //////////////////////////////////////////////////////////////////// } // end class HelloHarmony } // end BoxSprite /* This must only work in flex... [Embed(source="mbira01.mp3")] public var mbira01:Class; [Embed(source="mbira02.mp3")] public var mbira02:Class; [Embed(source="mbira03.mp3")] public var mbira03:Class; [Embed(source="mbira04.mp3")] public var mbira04:Class; [Embed(source="mbira05.mp3")] public var mbira05:Class; [Embed(source="mbira06.mp3")] public var mbira06:Class; [Embed(source="mbira07.mp3")] public var mbira07:Class; [Embed(source="mbira08.mp3")] public var mbira08:Class; [Embed(source="mbira09.mp3")] public var mbira09:Class; [Embed(source="mbira10.mp3")] public var mbira10:Class; [Embed(source="mbira11.mp3")] public var mbira11:Class; */ // Class public class Sound // Inheritance Sound Inheritance EventDispatcher Inheritance Object // Subclasses SoundAsset // // The Sound class lets you work with sound in an application. The Sound class lets you create a new Sound object, load and play an external MP3 file into that object, close the sound stream, and access data about the sound, such as information about the number of bytes in the stream and ID3 metadata. More detailed control of the sound is performed through the sound source — the SoundChannel or Microphone object for the sound — and through the properties in the SoundTransform class that control the output of the sound to the computer's speakers. // // To control sounds that are embedded in a SWF file, use the properties in the SoundMixer class. // // ------------- // Class public final class SoundChannel // Inheritance SoundChannel Inheritance EventDispatcher Inheritance Object // // The SoundChannel class controls a sound in an application. Every sound is assigned // to a sound channel, and the application can have multiple sound channels that are mixed // together. The SoundChannel class contains a stop() method, properties for monitoring the // amplitude (volume) of the channel, and a property for assigning a SoundTransform object // to the channel. // // ----------- // // Class public final class SoundTransform // Inheritance SoundTransform Inheritance Object // // The SoundTransform class contains properties for volume and panning.