I wanted to create a library for looping audio that didnt rely on COMPLETE events. I decided to create my own standingwave3 addons library. Check out the original standingwave3 project by MaxL0rd. Mine a work in progress and it gets the job done, on the byte level for that matter (No loop timers or anything). It works by taking in a Sound with beginning and ending loop points. Then it clones the loop sample a bunch of times based on the time provided in seconds. It should be straight forward to use. This is the code for the Main.as class in the
"looping" file in the "examples" folder:
package
{
// Imports.
import com.greensock.events.LoaderEvent;
import com.greensock.loading.LoaderMax;
import com.greensock.loading.MP3Loader;
import flash.display.Sprite;
import flash.events.Event;
import com.greensock.TweenMax;
import com.SW3.gadget.LoopGadget;
import flash.media.Sound;
// Class.
public class Main extends Sprite
{
// Vars.
private var loader:LoaderMax;// Using LoaderMax for ease of use.
// Constructor.
public function Main()
{
trace("Main");
loader = new LoaderMax( { name:"audio", onComplete:onSoundsLoaded } );
loader.append( new MP3Loader( "assets/Beat.mp3", { autoPlay:false } ) );
loader.append( new MP3Loader( "assets/Clap.mp3", { autoPlay:false } ) );
loader.append( new MP3Loader( "assets/Boom.mp3", { autoPlay:false } ) );
loader.load();
}
private function onSoundsLoaded(e:LoaderEvent):void
{
trace("onSoundsLoaded");
var looping:LoopGadget = new LoopGadget;
looping.addLoopSound( "Beat", e.currentTarget.content[ 0 ] as Sound, 0, 10 );
looping.addLoopSound( "Clap", e.currentTarget.content[ 1 ] as Sound, 0, 10 );
//looping.addLoopSound( "Boom", e.currentTarget.content[ 2 ] as Sound, 0, 10 ); // Commented out to test possible error.
looping.playLoop( "Beat" );// Play the "Beat" loop.
looping.playLoop( "Clap" );// Play the "Clap" loop.
looping.stopLoop( "Beat" );// Stop the "Beat" loop.
looping.playLoop( "Beat" );// Play the "Beat" loop.
looping.playLoop( "Beat" );// Play the "Beat" loop again to test if it would error out..
looping.stopAllLoops();// Stop all the loops.
looping.playLoops( [ "Beat", "Clap", "Boom" ] );// Play all the loops. Test to see if "Boom" will error out.
}
}
}
Check out the source files over here:
https://github.com/charlesclements/standingwave3-addons