Solved

Sound Problems in Action Script 2.0

Posted on 2006-11-13
2
175 Views
Last Modified: 2010-04-03
Hi,

I am coding in Action Script 2.0. For some reason in the code below the sound file only plays once, but it should keep on sounding.

sKick = new Sound(_root.kkSound_mc);
sKick.attachSound("kickRock");
Beat();

public function Beat(){
            clearInterval(beatID)
            beatID = setInterval(Beat, 100);
            sKick.start();
            //trace("beat="+ sKick.position)      
      }

When I trace the sKick sound in the function in is undefined after the first iteration - why does sKick disappear?
0
Comment
Question by:waffe
2 Comments
 
LVL 7

Accepted Solution

by:
muxxter earned 100 total points
ID: 17940103
Hi waffe.

You seem to be clearing an interval ID that doesn't exist. Also, the looping structure you're setting up is what's causing it to only play once.
Try something like:

var sKick = new Sound(_root.kkSound_mc);
sKick.attachSound("kickRock");

var beatID = setInterval(Beat, 100);

public function Beat() {
    sKick.start();
    //trace("beat="+ sKick.position)    
}
...

Keep in mind that you're going to be calling Beat() every 10th of a second. If that's what you want, that's cool, but I'd consider larger values for setInterval.

Cheers
Gav
0
 

Author Comment

by:waffe
ID: 18690865
Thanks muxxter:

Basically set interval sucks in flash!

waffe
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question