Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   Как заставить флеш проигрыватель запоминать громкость и не включаться? (http://www.flasher.ru/forum/showthread.php?t=172073)

freak 01.12.2011 06:30

Как заставить флеш проигрыватель запоминать громкость и не включаться?
 
Здравствуйте!

Есть флеш-проигрыватель, встроенный в сайт.
Помогите, пожалуйста, сделать так, чтобы при однократной остановке и переходе на следующие страницы сайта он больше не включался. Начинает играть постоянно заново.


Код AS1/AS2:

//
// INITIAL SETTINGS
//
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Var defaults
buffer = (menu_mc.bttn_mc._height)*2;
ID = 0;
bttnAlpha = 10
// Clip defaults
hover_mc._visible = false;
// Colour and alpha
controls_mc.bttnPlay.bg_mc._alpha = bttnAlpha;
controls_mc.bttnStop.bg_mc._alpha = bttnAlpha;
controls_mc.bg_mc._alpha = bttnAlpha;
controls_mc.bttnSound.bg_mc._alpha = bttnAlpha;
var setColour:Color = new Color(controls_mc.progress_mc.played_mc);
setColour.setRGB(_global.themeColour);
var setColour:Color = new Color(controls_mc.progress_mc.buffer_mc);
setColour.setRGB(_global.themeColour);
var setColour:Color = new Color(controls_mc.bttnSound.soundLevel_mc.bar_mc);
setColour.setRGB(_global.themeColour);
var setColour:Color = new Color(controls_mc.bttnSound.soundLevel_mc.bar);
setColour.setRGB(_global.themeColour);
//
// PROGRESS BAR CONTROLS
//
// Adjust playhead on progress bar press
controls_mc.progress_mc.onPress = function() {
        controls_mc.progress_mc.onEnterFrame = function() {
                if (this._xmouse<0) {
                        this.percentage = 0;
                } else if (((this._xmouse*this._xscale)/100)>=this._width) {
                        this.percentage = 100;
                } else {
                        this.percentage = Math.round((this._xmouse*this._xscale)/100/this._width*100);
                }
                seekTime = this.percentage/100*Math.round(my_sound.duration);
                my_sound.start(seekTime/1000);
                hover_mc._x = _xmouse;
                hover_mc._y = controls_mc._y+21;
                hover_mc.txt.text = timeDisplay;
                if (this._xmouse<0 or (this._xmouse*this._xscale)/100>this._width) {
                        hover_mc._visible = false;
                } else {
                        hover_mc._visible = true;
                }
        };
};
// Adjust playhead on progress bar release
controls_mc.progress_mc.onRelease = controls_mc.progress_mc.onReleaseOutside=function () {
        if (this.percentage == 100) {
                doPause();
        } else {
                doPlay();
        }
        hover_mc._visible = false;
        delete controls_mc.progress_mc.onEnterFrame;
};
//
// PRELOADER, TIME, MENUSCROLLING SCRIPT
//
onEnterFrame = function () {
        loading = my_sound.getBytesLoaded();
        filesize = my_sound.getBytesTotal();
        percentage = Math.round((loading/filesize)*100);
        controls_mc.progress_mc.buffer_mc._xscale = percentage;
        controls_mc.progress_mc.played_mc._xscale = (my_sound.position/my_sound.duration)*percentage;
        // Get current time
        seconds = my_sound.position/1000;
        minutes = Math.floor(seconds/60);
        if (minutes<10) {
                minutes = "0"+minutes;
        }
        seconds = Math.floor(seconds%60);
        if (seconds<10) {
                seconds = "0"+seconds;
        }
        if (durationDisplay == undefined) {
                durationDisplay = "-----";
        }
        timeDisplay = minutes+":"+seconds;
        time_txt.text = timeDisplay+" / "+durationDisplay;
};
//
// PLAYER CONTROL BUTTONS
//
// Stop
doStop = function () {
        my_sound.start(0);
        my_sound.stop();
        controls_mc.bttnPlay.icon_mc.gotoAndStop(2);
};
// Pause
doPause = function () {
        my_sound.stop();
        controls_mc.bttnPlay.icon_mc.gotoAndStop(2);
};
// Play
doPlay = function () {
        my_sound.start(my_sound.position/1000);
        controls_mc.bttnPlay.icon_mc.gotoAndStop(1);
};
controls_mc.bttnPlay.bttn.onPress = function() {
        if (controls_mc.bttnPlay.icon_mc._currentframe == 1) {
                doPause();
        } else {
                doPlay();
        }
};
controls_mc.bttnStop.bttn.onPress = function() {
        doStop();
};
//
// VOLUME SLIDER
//
controls_mc.bttnSound.soundLevel_mc._visible = false;
controls_mc.bttnSound.bttn.onRollOver = function() {
        this._parent.soundLevel_mc._visible = true;
};
controls_mc.bttnSound.bttn.onRollOut = controls_mc.bttnSound.bttn.onDragOut=function () {
        if (!this._parent.soundLevel_mc.hitTest(_root._xmouse, _root._ymouse, true)) {
                this._parent.soundLevel_mc._visible = false;
        }
};
controls_mc.bttnSound.soundLevel_mc.onRollOut = function() {
        this._visible = false;
};
// Adjust volume on slider press
controls_mc.bttnSound.soundLevel_mc.bar_mc._yscale = defaultVolume;
controls_mc.bttnSound.soundLevel_mc.onPress = function() {
        controls_mc.bttnSound.soundLevel_mc.onEnterFrame = function() {
                if (this._ymouse<0) {
                        volumeTo = 0;
                } else if (this._ymouse>this.bar._height) {
                        volumeTo = 100;
                } else {
                        volumeTo = (this._ymouse/this.bar._height)*100;
                }
                this.bar_mc._yscale = 100-volumeTo;
                my_sound.setVolume(100-volumeTo);
        };
};
// Adjust volume on slider release
controls_mc.bttnSound.soundLevel_mc.onRelease = controls_mc.bttnSound.soundLevel_mc.onReleaseOutside=function () {
        delete controls_mc.bttnSound.soundLevel_mc.onEnterFrame;
        this._visible = false;
};
//
// LOAD SOUND
//
var my_sound:Sound = new Sound(this);
my_sound.onLoad = function(success:Boolean) {
        if (success) {
                my_sound.setVolume(100);
                totalSeconds = this.duration/1000;
                minutes2 = Math.floor(totalSeconds/60);
                if (minutes2<10) {
                        minutes2 = "0"+minutes2;
                }
                seconds2 = Math.floor(totalSeconds)%60;
                if (seconds2<10) {
                        seconds2 = "0"+seconds2;
                }
                durationDisplay = minutes2+":"+seconds2;
        }
};
my_sound.onSoundComplete = function() {
        doForward();
};
//
// ON MENU PRESS
//
loadTrack = function () {
        my_sound.start();
        controls_mc.bttnPlay.icon_mc.gotoAndStop(1);
        my_sound.loadSound(_global.toLoad, true);
        holder_mc.gotoAndStop(1);
        holder_mc.holder.loadMovie(_global.AlbumArt);
        artistDisplay.htmlText = "<font color='#999999'>ARTIST: </font>"+_global.Artist;
        titleDisplay.htmlText = "<font color='#999999'>TITLE: </font>"+_global.Title;
};
loadTrack();


DaFive 01.12.2011 10:41

Записывайте данные о звуке в SheredObject. Затем при воспроизведении звука проверяйте условие. Если в шаредобжекте звук отключен - не начинать воспроизведение.


Часовой пояс GMT +4, время: 14:39.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.