Solved

Sound Problems in Action Script 2.0

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now