# Urgently need help in swapping part of the script

**URL:** <https://forum.kirupa.com/t/urgently-need-help-in-swapping-part-of-the-script/60350>\
**Category:** Uncategorized\
**Created:** [August 9, 2004, 7:19am UTC](https://forum.kirupa.com/t/urgently-need-help-in-swapping-part-of-the-script/60350 "2004-08-09T07:19:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![janice\_2k](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@janice\_2k](https://forum.kirupa.com/u/janice_2k)\
**Post date:** [August 9, 2004, 7:19am UTC](https://forum.kirupa.com/t/urgently-need-help-in-swapping-part-of-the-script/60350/1 "2004-08-09T07:19:21Z")

</div>

[font=verdana, arial, helvetica][size=2]Dear gurus/members,  
I am new to actionscript. I have created a script that will play server side sound object and client side mp3 files alternately. Now, I would like to play the client side mp3 first then only play server side sound object alternately. However, I have no idea how can I do so. The following is the code that need to be swapped:  
[/size][/font]

```auto

on (release) {
 stopAllSounds();
 var iddiscussion = 1;
 var numberFile = 3;
 var serverCtr = 0;
 var serverAudio = new Array("PE14_1a", "PE14_1c", "PE14_1e");
 function discussion() {
  server = new Sound();
  //serverFile = "PE14_1d";
  serverFile = serverAudio[serverCtr];
  server.attachSound(serverFile);
  //server side mp3
  server.start(0, 0);
  trace("SERVER "+serverFile+iddiscussion);
  server.onSoundComplete = function() {
   client = new Sound();
   clientFile = "[file:///c:/program](file:///c:/program) files/IEBAudioRecorder/test"+iddiscussion+".mp3";
   client.onLoad = function(success) {
	//define conditions for success first
	if (success) {
	 this.start();
	 trace("SOUND SUCCESS!!!");
	 client.onSoundComplete = function() {
	  //doesn't run if not success...
	  if (iddiscussion<numberFile) {
	   //no longer dependent on client.onSoundComplete
	   iddiscussion++;
	   trace("Add counter to "+iddiscussion);
	   serverCtr++;
	   discussion();
	  }
	 };
	} else {
	 //skip to the next file
	 trace("SOUND FAILED!!!");
	 if (iddiscussion<numberFile) {
	  //no longer dependent on client.onSoundComplete
	  iddiscussion++;
	  trace("Add counter to "+iddiscussion);
	  serverCtr++;
	  discussion();
	 }
	}
   };
   client.loadSound(clientFile, true);
   //load client mp3
   trace("CLIENT "+clientFile+iddiscussion);
  };
 }
 discussion();
}

```

[font=verdana, arial, helvetica][size=2]  
[/size][/font][font=verdana, arial, helvetica][size=2]How to make it in a way that it will play the client mp3 first then only server side sound object? Looking forward to some reply soon.  
[indent]

Thanks in advance,  
Janice[/size][/font]

[/indent]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 9, 2004, 7:22am UTC](https://forum.kirupa.com/t/urgently-need-help-in-swapping-part-of-the-script/60350/2 "2004-08-09T07:22:44Z")

</div>

hmm so u want it to play a sound unless an mp3 that a user selects is playing?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 9, 2004, 7:38am UTC](https://forum.kirupa.com/t/urgently-need-help-in-swapping-part-of-the-script/60350/3 "2004-08-09T07:38:05Z")

</div>

> [@Skribble](#):
>
> hmm so u want it to play a sound unless an mp3 that a user selects is playing?

I would like to swap the code above to make it play the client side mp3 first then play server side sound object.

For example: clientFile1.mp3-serverFile1, clientFile2.mp3-serverFile2 …etc

The code above allows me to play server side sound object first then play client side mp3. But now, instead of this, I want it to work another way round that starts with client side mp3 first, then play server side sound object. Hope its not confusing.

Thanks in advance,  
Janice
