views:

39

answers:

2

This is what I have as far as code, it is in the first frame of the movie.

nature = new Sound(this);
nature.attachSound("sound_naturally");
nature.setVolume(50);
nature.start(0,0);
nature.onSoundComplete = function(){
    nature.start(0,0);
}
trace(nature);

The trace outputs '[object Object]' at runtime.

I have the sound exporting to ActionScript with the link identifier 'sound_naturally', not exported to the first frame. I don't understand why it's not working. I did like the exact same thing like 3 hours ago and it worked fine, but I lost the file so I had to redo it and now it won't work at all.

Using Flash 10 with ActionScript 2.0

A: 

The second parameter in start() is telling it how many times to play the sound, and you have a 0 there.

Just try nature.start()

99miles
That was just how I left it as I was trying to figure out what was causing it not to play. Using just `start()` or even using `start(0,99)` both do nothing.
animuson
+1  A: 

Both start(0,0) or start() are valid. Your code is not the issue here.

What's happening is that the sound file doesn't get attached when exporting the SWF because it's only sitting in your library and not being used anywhere. Obviously that's why flash has "export in first frame", but that makes things tricky for preloading, right? So, another option would be this:

  • Place the sound on an unused frame of the timeline (ie: the LAST frame of your SWF). This will force flash to include the sound when publishing your SWF.
  • Preload your main movie, and make sure you call the script you have above only when everything's fully loaded.

This is a workaround solution, but ideally i would recommend loading sounds externally, using the loadSound() method.

Good luck !

sthg