Solved

Sound Problems in Action Script 2.0

Posted on 2006-11-13
2
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
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 live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

695 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