PDA

View Full Version : Alright I'm an idiot I need help **sound problem**



dynastyjp
October 13th, 2003, 01:20 PM
For some reason working with sound via actionscript just boggles my mind and if anyone points me to the extensive tutorial on flashkit.com (i forgot his name) I'll scream. It can't possibly be as hard as I'm making it out to be to work with sound. I just need a push i nthe right direction. :sigh: All I'm trying to do this..I can attach sound just fine that's the only part I do get. All I'm trying to do is this I have too attached sounds in a MC called "myloop" one called "thunder" the other "intro" thunder is just a quick 3-4 second sound effect..no need to worry about that. But what I need to do is have "intro" fade out when a button called "artist" is clicked..then when that button is clicked my external .swf will load and "intro2" to fade in and start playing. Sounds easy? It probably is; just not to me.

Now I have this wonderful AS from the tutorial mentioned above which reads as follows:

//copyright August 2002 by Kenny Bellew - kennybellew@hotmail.com
this.onEnterFrame = function () {

//
//Fade In
//
if (fadeIn01==1) {
// fadeIn01 can be set to 1 when a button is
// pressed, when a frame is reached or many other ways.

_root.myLoop.setVolume(myLoopVolume);
// Sets the volume for the sound object "myLoop"
// to the variable "myLoopVolume" every time the
// frame is entered during the movie clip loop.

myLoopVolume=myLoopVolume+5;
// Increments the variable "myLoopVolume" by 5.
// Increase or decrease this to change the speed of
// the fade from 0 to 100.

if (myLoopVolume>99) {
fadeIn01=0;
// This stops the "myLoopVolume" from incrementing
// by making the if-statement false once the volume
// reaches 100%.

} //Closes 2nd fadeIn if-statement
} //Closes 1st fadeIn if-statement
//
//Fade Out
//
if (fadeOut01==1) {
_root.myLoop.setVolume(myLoopVolume);
myLoopVolume=myLoopVolume-5;
if (myLoopVolume<5) {
_root.myLoop.stop("myLoop01");
fadeOut01=0;
}
}

and the Sound Objects:

//Grewell--Christia-1105_hifi.mp3 - freeware from Flashkit
myLoop = new Sound(myLoopMc);
myLoop.attachSound("myLoop01");
myLoopVolume=0
myLoop.setVolume(myLoopVolume);


and the button:
on (press) {
fadeOut01=1
}


So I figured great! I can just swap some names out and it'll work perfectly!...no..my sound quit working completely.

:puzzle:

I'm assuming this script needs to be placed in the _root timeline and not inside the MC "myloop." Correct, what am I doing wrong? I've been trying to figure out sound for ages and I just don't get it. Help??? :( please?

Voetsjoeba
October 13th, 2003, 01:46 PM
Let me place this code in AS tags. Where did you place it (except for the on(release) code) by the way ? All on the same timeline ?



this.onEnterFrame = function () {
//Fade In
if (fadeIn01==1) {
// fadeIn01 can be set to 1 when a button is
// pressed, when a frame is reached or many other ways.
_root.myLoop.setVolume(myLoopVolume);
// Sets the volume for the sound object "myLoop"
// to the variable "myLoopVolume" every time the
// frame is entered during the movie clip loop.
myLoopVolume=myLoopVolume+5;
// Increments the variable "myLoopVolume" by 5.
// Increase or decrease this to change the speed of
// the fade from 0 to 100.
if (myLoopVolume>99) {
fadeIn01=0;
// This stops the "myLoopVolume" from incrementing
// by making the if-statement false once the volume
// reaches 100%.
} //Closes 2nd fadeIn if-statement
} //Closes 1st fadeIn if-statement
//
//Fade Out
//
if (fadeOut01==1) {
_root.myLoop.setVolume(myLoopVolume);
myLoopVolume=myLoopVolume-5;
if (myLoopVolume<5) {
_root.myLoop.stop("myLoop01");
fadeOut01=0;
}
}
myLoop = new Sound(myLoopMc);
myLoop.attachSound("myLoop01");
myLoopVolume=0
myLoop.setVolume(myLoopVolume);
//--------------------------------------------
on (press) {
fadeOut01=1
}

dynastyjp
October 13th, 2003, 01:49 PM
Yes on the _root timeline

Oh and if you format the AS for me can you please use the names mentioned in my previous post? "intro", "intro2", "myloops" (mc), etc.

Thanks for your or anyone elses help.

dynastyjp
October 13th, 2003, 02:58 PM
Please help, I'm like begging. I need to wrap this project up in two days. Thanks!

Voetsjoeba
October 13th, 2003, 03:19 PM
Here you go :)



fadeIn = fadeOut=0;
myLoopVolume = 100;
myLoop = new Sound(this);
myLoop.attachSound("intro");
myLoop.setVolume(myLoopVolume);
myLoop.start(0, 999);
//--------------------------------
this.onEnterFrame = function() {
if (fadeIn) {
myLoop.setVolume(myLoopVolume);
myLoopVolume++;
if (myLoopVolume>99) {
fadeIn = 0;
}
}
if (fadeOut) {
myLoop.setVolume(myLoopVolume);
myLoopVolume--;
if (myLoopVolume<1) {
holder.loadMovie("main.swf");
myLoop.stop();
myLoop.attachSound("intro2");
myLoop.start(0, 999);
fadeIn = 1;
fadeOut = 0;
}
}
};
artists.onRelease = function() {
fadeOut = 1;
};

dynastyjp
October 13th, 2003, 05:43 PM
Wow!!! Thanks and I place this in the main timeline correct? Or do they go in seperate areas? Last question and I'll leave you alone..I promise ;).

Voetsjoeba
October 14th, 2003, 01:51 PM
This goes in the main timeline indeed :) Also, make sure artists is on the main timeline. If not, just change the path in

artists.onRelease = function() {
fadeOut = 1;
};

to


artistscontainer.artists.onRelease = function() {
fadeOut = 1;
};

for example :)

dynastyjp
October 14th, 2003, 02:35 PM
Thanks!! and check your PM!!