A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Flash 8: Get a sound to play if it hasn't already started?

  1. #1
    Senior Member
    Join Date
    Jun 2001
    Posts
    219

    Flash 8: Get a sound to play if it hasn't already started?

    Hi guys,

    I have a typewriting effect that exists on 6 frames - on frame one the says what characters to type and which character comes next and on frame six it tells it to go back to the begining.

    I also have a typewriting sound effect - Is there any way I can tell the flash to play the typewriting sound if it's not already playing, every time it hits that first frame?

  2. #2
    Senior Member
    Join Date
    Oct 2003
    Location
    NYC
    Posts
    107
    This might work. I haven't tested it. But it should give you some idea.

    On frame one:

    Code:
    var isPlaying = false;
    var sndFx = new Sound(this);
    sndFx.attachSound("linkageNameOfYourSound");
    sndFx.onSoundComplete = function() {
      isPlaying = false;
    }
    
    function playSndFx() {
     sndFx.start();
     isPlaying = true;
    }
    
    playSndFx();
    On each subsequent frame:

    Code:
    if(!isPlaying) {
     playSndFx();
    }
    Or try writing a function that does does the typing and called by setInterval. So everytime the function executes you play the sound.
    Last edited by finksmart; 02-24-2007 at 01:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center