Forum Topic: Adding sound effects to flash

(170 views • 5 replies)

This topic is 1 page long.

<< < > >>
None

Mp3-Lock

Reply To Post Reply & Quote

Posted at: 9/5/07 08:18 PM

Mp3-Lock EVIL LEVEL 16

Sign-Up: 08/20/03

Posts: 514

Ok so im trying to get it so when I press the up button in my racer, you hear an engine sound, I know this is easy but Im not sure what the best code for it is. I want to add it in the movement code but anyone know how to do this?


None

Denvish

Reply To Post Reply & Quote

Posted at: 9/5/07 08:30 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

Something like

createEmptyMovieClip("SA", 56789);
Engine=new Sound(SA);
Engine.attachSound("linkagename");
engineOn=0; //BOOLEAN

onClipEvent(enterFrame){
if(Key.isDown(Key.UP)){
if(!engineOn){
Engine.start(0,9999);
engineOn=1;
}
}else{
if(engineOn){
Engine.stop("linkagename");
engineOn=0;
}
}
}

- - Flash - Music - Images - -

BBS Signature

None

Mp3-Lock

Reply To Post Reply & Quote

Posted at: 9/5/07 09:59 PM

Mp3-Lock EVIL LEVEL 16

Sign-Up: 08/20/03

Posts: 514

this, sort of works but the sounds loop over each other when you keep pressing the up button and they dont stop playing when you are done


None

Mp3-Lock

Reply To Post Reply & Quote

Posted at: 9/5/07 10:58 PM

Mp3-Lock EVIL LEVEL 16

Sign-Up: 08/20/03

Posts: 514

Does anyone else know? I have checked all over the internet and I cant find an answer,


None

sandypaw

Reply To Post Reply & Quote

Posted at: 9/5/07 11:06 PM

sandypaw DARK LEVEL 10

Sign-Up: 06/28/07

Posts: 1,268

stopAllSounds(); =)

=3


None

Denvish

Reply To Post Reply & Quote

Posted at: 9/6/07 04:14 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

I forgot to refer to _root, I didn't test it. The first four lines should go on main timeline first frame, then this lot should go on the MC

If you don't want it to loop, use _root.Engine.start(), not _root.Engine.start(0,9999);

onClipEvent(enterFrame){
if(Key.isDown(Key.UP)){
if(!_root.engineOn){
_root.Engine.start(0,9999);
_root.engineOn=1;
}
}else{
if(_root.engineOn){
_root.Engine.stop("linkagename");
_root.engineOn=0;
}
}
}

- - Flash - Music - Images - -

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 07:21 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!