Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Use actionscript to trigger independant sound loop and reset

New Here ,
Sep 10, 2014 Sep 10, 2014

Hello guys,

I have a bit of experience with flash and actionscript, but due to the fact that I don't use it frequently, it happens that I forgot most of what I can do.

I am about to start a sound project but I wanted to make sure it works before starting research.

I want to use actionscript to click on letters that will display on the screen, and each letter will trigger an audio loop independantly, hence creating music.I also want to be able to reset the animation, erase all letters and sounds in order to restart. Actually that is the main question

If it is possible, how ? Would you mind giving me some tips for a "kickstart"

TOPICS
ActionScript
329
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 10, 2014 Sep 10, 2014

Look into using the Sound class so that you can control which sound plays when.  Google "AS3 Sound tutorial"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2014 Sep 11, 2014
LATEST

Is it possible, with flash to put different sounds triggered by a set of a buttons into a track and play this track in a loop ?

I want to make it so when you press for example buttons A, then B, then C, it will play the sounds A, B and C respectively in an infinite loop. So when you click A, B, C, D, E, it will play ABCDE.

EDIT: I succeeded ! I had to use arrays to do that. But now I would like that instead of putting the sounds automatically into the array at the beginning (red part), I want to be able to put by clicking on different buttons. It means if I click "A" first it will put the A into index 0, then B and put into index 1, then C and put into index 2, and so on. Also loop it indefinitely. How can ?

var musicTrack = new Array();

var aNote:a = new a();

var bNote:b = new b();

musicTrack.push(aNote);

musicTrack.push(bNote);

musicTrack.push(aNote);

var musicChannel:SoundChannel;

var currentSongIndex:int;

function  onPlayBtnPressed() {

  currentSongIndex = 0;

  playSongFromIndex(currentSongIndex);

}

function playSongFromIndex(songIndex:int) {

  musicChannel = musicTrack[songIndex].play();

  musicChannel.addEventListener(Event.SOUND_COMPLETE, songFinished);

  currentSongIndex++;

}

function songFinished(e:Event) {

  if (currentSongIndex < musicTrack.length) {

       playSongFromIndex(currentSongIndex);

  } else  {

       currentSongIndex=0;

  }

}

onPlayBtnPressed();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines