loading audio through xml


i new action script 3 , have 1 problem.am loading audio xml files.

 

while clicking on button loading audio.i have 4 buttons , 4 audios there in xml.when click on 1 loading audio, when click 2 , 3 , 4 audio not loading

it throwing error

error: error #2037: functions called in incorrect sequence, or earlier call unsuccessful.

    @ flash.media::sound/_load()

    @ flash.media::sound/load()

    @ answerquestions_as3_fla::maintimeline/showans()

 

this code

 

sound.load(new urlrequest(audio_arr[aud_num-1]+".mp3"));

    sound.addeventlistener(event.complete,loadaud);

    schannel.addeventlistener(event.sound_complete,stopaud);

 

    function loadaud(e:event) {

        trace("play aud");

        schannel=sound.play();

    }

 

    function stopaud(e:event) {

        trace("audio stop");

        schannel.stop();

        sound.close();

    }

have tested audio_arr[aud_num-1]+".mp3" see returns? sure you're getting file name expect?

 

from have looks array audio_arr contains names of sound files. might simpler add ".mp3" extension each file name in array rather concatenating @ urlrequest(). if doing this, file name in 1 step assign local variable , use variable in urlrequest().



More discussions in ActionScript 3


adobe

Comments