Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
emsee

How can I make sounds overlap with MP3Loader?

Recommended Posts

I have three tweens, each one with a sound effect called on start:

//simplified code:
TweenMax.to(this, 10, {alpha:1, delay:1, onStart:playSound1});
TweenMax.to(this, 10, {alpha:1, delay:2, onStart:playSound2});
TweenMax.to(this, 10, {alpha:1, delay:3, onStart:playSound3});

function playSound1():void
{
	LoaderMax.getLoader("sound1").playSound();
}

function playSound2():void
{
	LoaderMax.getLoader("sound2").playSound();
}

function playSound3():void
{
	LoaderMax.getLoader("sound3").playSound();
} 

I would like the sounds to overlap, but instead, the first sound is cut off by the second, which in turn is cut off by the third.

 

Can I get all three sounds overlapping?

 

Is there a way to access the loaded sound object & play it through a separate channel manually?

 

 

Thanks

Link to post
Share on other sites

Not sure why your sounds are getting cut off.

I just built a very similar and simple demo and had no problems.

 

Full code:

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;


var chicken:MP3Loader = new MP3Loader("chicken.mp3", {autoPlay:false});
var mystery:MP3Loader = new MP3Loader("mystery.mp3",{autoPlay:false});


var sounds:LoaderMax = new LoaderMax({onComplete:allLoaded});
sounds.append(chicken);
sounds.append(mystery);
sounds.load();


function allLoaded(e:LoaderEvent):void {
trace("all loaded"); 


TweenMax.to(mc1, 10, {x:400, delay:1, onStart:playSound, onStartParams:["chicken.mp3"]});
TweenMax.to(mc2, 10, {x:400, delay:4, onStart:playSound, onStartParams:["mystery.mp3"]});
}




function playSound(loaderURL) {
LoaderMax.getLoader(loaderURL).playSound();
}

download FLA and Sounds here: http://ge.tt/41FCWMT1/v/0?c (use your own greensock classes)

 

If you still have problems please make and provide a very simple demo that illustrates the problem.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×