Solved

Sound Problems in Action Script 2.0

Posted on 2006-11-13
2
177 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML 5 or Flash 7 489
Stop Ads in Browser Google Chrome 3 547
Streaming to Flash Media Server with ffmpeg, crashes on start 3 264
free flash maker 5 216
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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 goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

828 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