PDA

View Full Version : if else.. FLV Player


KTA
01-09-2008, 05:11 AM
This actualy works if user decides not to turn off the sound when first arriving to the site.. I was hoping that if it was turned into an "if else" statement it may solve my problem.

Problem: I have background music playing when entering the site however if the user turns off the sound when they arrive into the site THEN were to click on the video the sound would start up again after the video ends.

I want it to say: Hey if the music is on then turn it back on after the video ends BUT if the music is off leave it off when the video ends.

Lastly the video is not on auto play the user needs to press play.

var enventListener = new Object();
enventListener.playing= function(evntObj){
_root.music.stop();
}
player.addEventListener("playing",enventListener);

var enventListener = new Object();
enventListener.complete= function(evntObj){
_root.music.start(0,999);
}
player.addEventListener("complete",enventListener);

THANKS FOR ANY ADDITIONAL HELP!

atomic
01-09-2008, 05:47 AM
Condition it to an extra variable...

var music_off:Boolean = false;

If the music is set to off by the user...

music_off = true;

And...

var enventListener = new Object();
enventListener.complete= function(evntObj){
if(!music_off){
_root.music.start(0,999);
}
}
player.addEventListener("complete",enventListener) ;

KTA
01-09-2008, 06:37 AM
Thanks for the reply but I still can't get it to work.

Maybe I misunderstood the "Condition it to an extra variable..."

var music_off:Boolean = false;
If the music is set to off by the user...
music_off = true;


I pasted the code into my frame but it doesn't seem to do anything.. errr :(

var music_off:Boolean = false;
music_off = true;

var enventListener = new Object();
enventListener.complete= function(evntObj){
if(!music_off){
_root.music.start(0,999);
}
}
player.addEventListener("complete",enventListener) ;


I do have this bit of of code on my Sound Countrol clip

onClipEvent(load)
{
_root.soundstatus="on";
_root.music=new Sound();
_root.music.attachSound("loop");
_root.music.start(0,999);
maxvolume=100;
minvolume=0;
}

onClipEvent(enterFrame)
{
if(_root.soundstatus=="on") {step=5}
if(_root.soundstatus=="off") {step=-5}

maxvolume+=step;

if (maxvolume>100) {maxvolume=100;}
if (maxvolume<0) {maxvolume=0;}

_root.music.setVolume(maxvolume);
}

atomic
01-09-2008, 08:01 AM
var music_off:Boolean = false;
// NOT HERE - music_off = true;

var enventListener = new Object();
enventListener.complete= function(evntObj){
if(!music_off){
_root.music.start(0,999);
}
}
player.addEventListener("complete",enventListener) ;


I do have this bit of of code on my Sound Countrol clip

onClipEvent(load)
{
_root.soundstatus="on";
_root.music=new Sound();
_root.music.attachSound("loop");
_root.music.start(0,999);
maxvolume=100;
minvolume=0;
}

onClipEvent(enterFrame)
{
if(_root.soundstatus=="on") {step=5}
if(_root.soundstatus=="off") {step=-5}

maxvolume+=step;

if (maxvolume>100) {maxvolume=100;}
if (maxvolume<0) {maxvolume=0; music_off = true;} // BUT HERE

_root.music.setVolume(maxvolume);
}

KTA
01-10-2008, 04:13 AM
Thanks for taking the time to help me out!! I'll give it a try.

:)

atomic
01-10-2008, 04:39 AM
If it still doesn't work, attach your .fla.