Solved

Sound Problems in Action Script 2.0

Posted on 2006-11-13
2
172 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
Comment Utility
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
Comment Utility
Thanks muxxter:

Basically set interval sucks in flash!

waffe
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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 select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

772 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

10 Experts available now in Live!

Get 1:1 Help Now