S.T.A.R.S
S.T.A.R.S

Reputation: 37

How to set the volume of audio player to a default 20% on my flash web page

I need to have my audio player start with a default 20% than 100%. I tried to deduct some digits in the related actionscript and all I did was set the entire bar to 20%... I even tried to pull the volume backward but that's not the way it works. (I'm not a coder btw.. I just play with codes to understand how they work)

I guess it has something to do with the actionscript below but in case that I'm wrong, I also attached the source .fla...

//
// SOUND CONTROL COMPONENT
//
// Initial Settings
//
originY = volBttn._y;
originX = volBttn._x;
maxX = scrollBar._width-volBttn._width;
eq_mc.gotoAndStop(Math.round(1+(_global.volumeAmount/20)));
hover_mc._visible = false;
// Equaliser
doEQ = function () {
    eq_mc.eq_all._yscale = _global.volumeAmount;
};
resetSlider = function () {
    volBttn._x = Math.round((scrollBar._width-volBttn._width)*(_global.volumeAmount/100));
};
// Volume button onPress
volBttn.onPress = function() {
    this.startDrag(0, 0, originY, maxX, originY);
    hover_mc.onEnterFrame = function() {
        _global.volumeAmount = Math.round((volBttn._x/(scrollBar._width-volBttn._width))*100);
        doEQ();
        this.txt.text = _global.volumeAmount+"%";
        this.txt._width = this.txt.textWidth+10;
        this.bg._width = this.txt._width+10;
        this._x = volBttn._x+volBttn._width/2;
        this._y = volBttn._y;
        hover_mc._visible = true;
    };
};
// Volume button onRelease
volBttn.onRelease = volBttn.onReleaseOutside=function () {
    delete hover_mc.onEnterFrame;
    this.stopDrag();
    hover_mc._visible = false;
    this.gotoAndPlay('rollOut');
};
volBttn.onRollOver = function() {
    this.gotoAndPlay('rollOver');
};

I also can't increase or decrease the volume by clicking on the navigator bar. I have to click and hold that small navigator and then drag it to left or right. It makes it a bit difficult not to mention that there's no mute button. How may I fix it ?

http://www.mediafire.com/download/3olq6jthewr5t26/index.rar

Upvotes: 1

Views: 666

Answers (1)

akmozo
akmozo

Reputation: 9839

I decompiled your two swf files : index20.swf and index100.swf, but you didn't what I meant because in both of them I find :

...

// it's the 89th line of the 1st frame of your main timeline, here you should put 20
_global.volumeAmount = 100;      
_global.volSaved = "";

...

So to get your swf working as you want, you should set :

_global.volumeAmount = 20;

And then in your soundControl_mc.volume_mc MovieClip you have to execute the resetSlider() and doEQ() functions to set the initial position of the volume slider and initilize the equalizer, you should call them after their definitions of course if you are in the timeline of soundControl_mc.volume_mc or after setting _global.volumeAmount in the main timeline :

resetSlider();
doEQ();

Which will give you something like this :

enter image description here

You can download your project here.

Hope that can help.

Upvotes: 1

Related Questions