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

problem with mvie sound not playing automatically

New Here ,
Jul 02, 2013 Jul 02, 2013

Copy link to clipboard

Copied

hi there

i'm a bit of a novice when it comes to flash and as3 but I have manged to put together an animation with a voiceover. The voiceover plays along and parts of the animation correspond to what is being said in the voiceover so it's imperative that they play together.

I've managed to add a play and pause button which are working ok however the animation starts playing automatically when testing but the voiceover doesn't. You have to click the pause button foloowed by the play button to get the voiceover to play. Once that's done the play and pause buttons work perfectly. However, they voiceover and animation need to start at exactly the same time as the voiceover references the animation.

I hope I'm making sense!! I'm so close to getting this working but I just can't seem to figure this out. Any help would be much appreciated as I'm getting quite lost with as3!!

I have 3 layers in the flash file, one with the content (movieclip called dude), one with the play/pause buttons (go and halt) and the actionscript (see below).

import flash.events.MouseEvent;

var mySound:Sound = new voiceover();

var myChannel:SoundChannel = new SoundChannel();

var lastPosition:Number = 0;

var soundIsPlaying:Boolean = true;

go.addEventListener(MouseEvent.CLICK, startplaying);

function startplaying(event:MouseEvent):void{

    dude.play();

    if(!soundIsPlaying){

    myChannel = mySound.play(lastPosition);

    }

}

halt.addEventListener(MouseEvent.CLICK, stopplaying);

function stopplaying(event:MouseEvent):void{

    dude.stop();

    lastPosition = myChannel.position;

    myChannel.stop();

    soundIsPlaying = false;

}

I'd really appreciate any help as my deadline is looming and I'm so stuck on this last hurdle!

Thanks in advance 

TOPICS
ActionScript

Views

379

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Jul 02, 2013 Jul 02, 2013

Try setting the soundIsPlaying value to false instead of true in the beginning of your code.  In the start playing function the sound only starts if it is not playing, but by having that value set to be true at the start, it thinks the sound is playing...

if(!soundIsPlaying){   // is testing if the sound is NOT ( ! ) playing

Votes

Translate

Translate
LEGEND ,
Jul 02, 2013 Jul 02, 2013

Copy link to clipboard

Copied

Try setting the soundIsPlaying value to false instead of true in the beginning of your code.  In the start playing function the sound only starts if it is not playing, but by having that value set to be true at the start, it thinks the sound is playing...

if(!soundIsPlaying){   // is testing if the sound is NOT ( ! ) playing

Votes

Translate

Translate

Report

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 ,
Jul 02, 2013 Jul 02, 2013

Copy link to clipboard

Copied

Thank you so much that works perfectly now

Votes

Translate

Translate

Report

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 ,
Jul 02, 2013 Jul 02, 2013

Copy link to clipboard

Copied

LATEST

You're welcome

Votes

Translate

Translate

Report

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