Sidiras Chris
Sidiras Chris

Reputation: 31

calling a function from inside another function

I need a little help. I'm trying to create a loop of three functions. I created the first loop but I can not get to the first function after the 3rd one is done. I think the best solution is to call the first one inside the third one, but I'm not sure this is the best way. Anyway this is my code:

function LOADALL(event:MouseEvent):void{
if (ConditionC == "NotPlaying"){
    ConditionC = "Playing";
    var urlRequest:URLRequest = new URLRequest(Sounds_Array[i]);
    var wav:URLLoader = new URLLoader();
    wav.dataFormat = 'binary';
    wav.load(urlRequest);
    wav.addEventListener(Event.COMPLETE, playWav);
    }
}

function playWav(e:Event):void{
    var tts:WavSound = new WavSound(e.target.data as ByteArray);
    var channel:WavSoundChannel = tts.play();
    channel.addEventListener(Event.SOUND_COMPLETE, completeHandler)
}

function completeHandler(e:Event):void{
    ConditionC = "NotPlaying";
trace ("hello");
LOADALL();
}

The error is in the 2nd from the end line ( LOADALL(); )

Any help?

Upvotes: 0

Views: 217

Answers (1)

Tom
Tom

Reputation: 8180

You are trying to call the LOADALL function without any arguments, when in fact it requires one argument: event - which is probably why you are getting an error. Since you are not using event in LOADALL, just pass null, ie:

LOADALL(null);

Upvotes: 1

Related Questions