Groups | Blog | Home
all groups > flash actionscript > july 2004 >

flash actionscript : Initialize and load sound object from child MC


Dir2Flash
7/28/2004 8:36:06 PM
I currently have a child movie clip that is embedded inside another movie clip
("mc_MainMovie"). The purpose of the child clip is to initialize several sound
objects in the parent movie, load external MP3 files for each object, and track
download progress.

Unfortunately I can't even initialize and load the first sound object using
the following code:

mc_MainMovie.sound1 = new Sound(mc_MainMovie);
mc_MainMovie.sound1.loadSound("sound1.mp3");

Does anyone have any suggestions how to make this work? Any help is much
appreciated!

Phil
Jack.
7/28/2004 9:10:11 PM
try -
sound1 = new Sound(mc_MainMovie);
// this ties the sound Object - sound1 to the
// timeline of the mc and allows for individual
// control over that sound

sound1.loadSound("sound1.mp3",false);
// false for event, true to stream

to detect download progress you would check for -
sound1.getBytesLoaded();

hth
Dir2Flash
7/29/2004 5:22:19 PM
Jack,

Thanks again for the tip. For some reason, I could successfully load the
sound object (as Flash is correctly returning the bytes loaded), but I could
not get the sound to play by using sound1.start(); in the mc_MainMovie movie
clip.

This what I have in the child clip:
sound1 = new Sound(mc_MainMovie);
sound1.loadSound("sound1.mp3", false);
**As I mentioned, the file seems to be loading fine

This is what I have in the parent clip (mc_MainMovie):
sound1.start();

The only way I could get the sound to play is to make the sound object global
(which is not a good idea for multiple sound objects--right?). Any other
suggestions?

Thanks,
Phil
Jack.
7/29/2004 8:11:18 PM
from the clip, use - _parent.sound1.start();

as you have created -
_level0.sound1 = [object #2, class 'Sound'] {
duration:[getter/setter] 3448,
position:[getter/setter] 0
}

_global.sound1 = new Sound(mc_MainMovie);
would open the scope of sound1 to all timelines,
and you would use -on(press){ sound1.start(); }

hth


AddThis Social Bookmark Button