;

PDA

Click to See Complete Forum and Search --> : newbie with simple sound problem


bansche
08-26-2006, 06:14 PM
Hello,
i think there is a loop in my head and i couldn't fix a simple problem.
I want to start a sound in a movieclip under a simple condition like here:
//Width = 600
onClipEvent(load){
a = 4;
this._x = -582;
this._y = 117;
}
onClipEvent(enterFrame){
this._x += a;
if (this._x > 171)[
a = 0]
}
so if this._x exceeds 171 or != the sound should start.
I tried a lot, but at all times the sound starts at the beginning of the MC.
Thank You for helping.
Best wishes from Germany
Bansche

blanius
08-27-2006, 01:14 AM
Hmmmmm.....
I don't see where you load or play the sound. I see you setting a variable called "a" and the train stops incrementing the ._x when it exceeds 171 but that's all. But assuming you have a sound loaded in a sound object like:

mySound=new Sound()
mySound.loadSound("train.mp3",false);

then in you loop you could but

onClipEvent(enterFrame){
_root.txt1.text=this._x
this._x += a;
if (this._x > 171){
a = 0
mySound.play();
}

Also I noticed you had
onClipEvent(enterFrame){
_root.txt1.text=this._x
this._x += a;
if (this._x > 171)[
a = 0]

}

and was surprised it worked with [] instead of {}

}

bansche
08-27-2006, 07:31 PM
:confused: but i tried al lot of things you suggest and i didn't hear sound all the times.
I think this is caused by less knowledge about AS, specially in terms of -_root and these things.
I found at least another way:
in the trainMC i added another frame. Then i added a new MC with a swf including the mp3) inside to this frame.
At first frame i put a stop
and the AS is the following:
onClipEvent(enterFrame){
_root.txt1.text=this._x
this._x += a;
if (this._x > 171){
a = 0
nextFrame()};
}
At this time my solution fits my problem.
Sorry for not understanding Your solution, but i am just an (unemployed) truckdriver in Germany, not a computer specialist
Best wishes from Germany
Bansche

blanius
08-27-2006, 10:05 PM
Not to worry Bansche, I just didn't see your audio in the file you uploaded so it was a guess on my part.