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

Help pls. (mp3 using flash)

New Here ,
Feb 14, 2016 Feb 14, 2016

Im not really familiar with adobe flash and especially coding.so pls bear with me T.T

i managed to search for a working code for pause/start/play buttons for my mp3.

here is the code:

stop();

var mySound:Sound;

var myChannel:SoundChannel;

var soundIsPlaying:Boolean = false; //prevent play btn overlap

var p:uint = 0;

mySound = new Sound;

mySound.load(new URLRequest("Fall Out Boy - Beat It ft. John Mayer.mp3"));

btn_play.addEventListener(MouseEvent.CLICK, playSound);

btn_stop.addEventListener(MouseEvent.CLICK, stopSound);

btn_pause.addEventListener(MouseEvent.CLICK, pauseSound);

function stopSound(myEvent:MouseEvent):void {

myChannel.stop();

p = 0;

soundIsPlaying = false;

}

function playSound(myEvent:MouseEvent):void {

if (!soundIsPlaying) {

myChannel = mySound.play(p); //play song location (p)

soundIsPlaying = true;

  }

}

function pauseSound(myEvent:MouseEvent):void {

if (soundIsPlaying) {

p = Math.floor(myChannel.position);

myChannel.stop();

soundIsPlaying = false;

}

}

//prev and next buttons//

btn_next.addEventListener(MouseEvent.CLICK, MightWork);

function MightWork(event:MouseEvent):void

{

  nextFrame();

}

btn_prev.addEventListener(MouseEvent.CLICK, MightNot);

function MightNot(event:MouseEvent):void

{

  prevFrame();

}

im going to make five frames, with five different songs on the action script. but when i press previous or next button. my songs would overlap each other...

"SoundMixer.stopAll()" wont work for me... pls help.

TOPICS
ActionScript
261
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
Community Expert ,
Feb 14, 2016 Feb 14, 2016

stop();

var mySound:Sound;

var myChannel:SoundChannel;

var soundIsPlaying:Boolean = false; //prevent play btn overlap

var p:uint = 0;

mySound = new Sound;

mySound.load(new URLRequest("Fall Out Boy - Beat It ft. John Mayer.mp3"));

btn_play.addEventListener(MouseEvent.CLICK, playSound);

btn_stop.addEventListener(MouseEvent.CLICK, stopSound);

btn_pause.addEventListener(MouseEvent.CLICK, pauseSound);

function stopSound(myEvent:MouseEvent):void {

myChannel.stop();

p = 0;

soundIsPlaying = false;

}

function playSound(myEvent:MouseEvent):void {

if (!soundIsPlaying) {

myChannel = mySound.play(p); //play song location (p)

soundIsPlaying = true;

  }

}

function pauseSound(myEvent:MouseEvent):void {

if (soundIsPlaying) {

p = Math.floor(myChannel.position);

myChannel.stop();

soundIsPlaying = false;

}

}

//prev and next buttons//

btn_next.addEventListener(MouseEvent.CLICK, MightWork);

function MightWork(event:MouseEvent):void

{

myChannel.stop();

  nextFrame();

}

btn_prev.addEventListener(MouseEvent.CLICK, MightNot);

function MightNot(event:MouseEvent):void

{

myChannel.stop();

  prevFrame();

}

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 ,
Feb 14, 2016 Feb 14, 2016

thanks for helping me...the code you suggested managed to stop the overlapping of songs by pressing the "next or previous" buttons, and then clicking play..but if i'm going to click the "stop or pause" buttons in one of my songs it would overlap again. do you know any other way?.. thanks again, you've been a big help

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
Community Expert ,
Feb 14, 2016 Feb 14, 2016
LATEST

not unless you're using some code you're not showing.

in that case, make sure you use

if(myChannel){

myChannel.stop();

}

before you execute

myChannel=whatever.play(();

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