PDA

View Full Version : New sound on frames (actionscript)



basquet_57
February 15th, 2007, 02:20 PM
I have been working on a flash animation that plays different sound files on each frame. (Either in the main timeline or in a separate movie clip).

I was hoping that would work:


if (caps._currentframe == 1) {
speech.loadSound("track1.mp3", true);
}
else if (caps._currentframe == 2) {
speech.loadSound("track2.mp3", true);
}
else if (caps._currentframe == 3) {
speech.loadSound("track3.mp3", true);
}


However, only the first file plays - since it's on the first frame. When tracing _currentframe, only the first frame is traced. I got next and back buttons that user clicks to move to the different frames.

PSEUDO code of what I want (all in the 1st actionscript frame)
If this frame = 1, play sound 1;
If this frame = 2, play sound 2;
if this frame = 3, play sound 3;

By having all of these in the first frame, I can more easily (I hope) do a pause/mute button. And the code will all be in one place instead of scattered across different MCs and frames.

NOTE:
I can just attach the sound file to the different key frame and it works fine. Or use actionscript on each key frame and it works ok. However, turning allowing the user to turn the sound OFF isn't working well (it "unmutes" in every frame).
Again, my goal is to control all sounds from the 1 keyframe.

Thank you in advance.

basquet_57
February 15th, 2007, 06:47 PM
Another option is to make movie clips trigger the new mp3s, instead of reffering to a particular key frame.

But I am not sure how to go about that.


PSEUDO code:

When MC1 enters frame
play song

When MC2 enters frame
play song 2.

etc..

----- (again all this from 1 frame, not in the individual frames)

Any help is appreciated.

basquet_57
February 20th, 2007, 12:42 PM
Anyone?


I have been working on a flash animation that plays different sound files on each frame. (Either in the main timeline or in a separate movie clip).

I was hoping that would work:


if (caps._currentframe == 1) {
speech.loadSound("track1.mp3", true);
}
else if (caps._currentframe == 2) {
speech.loadSound("track2.mp3", true);
}
else if (caps._currentframe == 3) {
speech.loadSound("track3.mp3", true);
}


However, only the first file plays - since it's on the first frame. When tracing _currentframe, only the first frame is traced. I got next and back buttons that user clicks to move to the different frames.

PSEUDO code of what I want (all in the 1st actionscript frame)
If this frame = 1, play sound 1;
If this frame = 2, play sound 2;
if this frame = 3, play sound 3;

By having all of these in the first frame, I can more easily (I hope) do a pause/mute button. And the code will all be in one place instead of scattered across different MCs and frames.

NOTE:
I can just attach the sound file to the different key frame and it works fine. Or use actionscript on each key frame and it works ok. However, turning allowing the user to turn the sound OFF isn't working well (it "unmutes" in every frame).
Again, my goal is to control all sounds from the 1 keyframe.

Thank you in advance.