pkfun
26.08.2006, 21:37
Вот, такой код:
var soundSw = false;
var pos:Number = 0;
//создаем кнопку включения/выключения звука
this.attachMovie("sinMusic", "sinMusic", this.getNextHighestDepth());
this.sinMusic._x = 40;
this.sinMusic._y = 40;
this.attachMovie("sinMusicHit", "sinMusicHit", this.getNextHighestDepth());
this.sinMusicHit._x = 40;
this.sinMusicHit._y = 40;
this.sinMusicHit._visible = false;
sinMusic.hitArea = sinMusicHit;
//
//функция которая включает и выключает звук
this.sinMusic.onRelease = function():Void {
if (soundSw == false) {
this._parent;
sinMusic._alpha = 30;
soundSw = true;
pos = snD.position/1000;
snD.stop();
} else {
soundSw = false;
this._parent;
sinMusic._alpha = 100;
snD.start(pos);
}
};
//создаем поле sounD и присоединяем к нему муз. файл из библиотеки
this.createEmptyMovieClip("sounD", this.getNextHighestDepth());
//
//создаем объект для звука Zvk
var snD:Sound = new Sound(sounD);
//
//прикрепляем звук Zvk к полю sounD
snD.attachSound("Zvk");
//
//устанавливаем для звука Zvk уровень громкости 90%
snD.setVolume(90);
snD.start();
//запускаем звук с начала, когда он доходит до конца
snD.onSoundComplete = function():Void {
snD.start();
};
При отключении звука происходят неприятные щелчки. Как бороться? :(
К вопросу прилагаю файл fla. 56 Килобайт. Выполнен для 8 флэш.
15052
var soundSw = false;
var pos:Number = 0;
//создаем кнопку включения/выключения звука
this.attachMovie("sinMusic", "sinMusic", this.getNextHighestDepth());
this.sinMusic._x = 40;
this.sinMusic._y = 40;
this.attachMovie("sinMusicHit", "sinMusicHit", this.getNextHighestDepth());
this.sinMusicHit._x = 40;
this.sinMusicHit._y = 40;
this.sinMusicHit._visible = false;
sinMusic.hitArea = sinMusicHit;
//
//функция которая включает и выключает звук
this.sinMusic.onRelease = function():Void {
if (soundSw == false) {
this._parent;
sinMusic._alpha = 30;
soundSw = true;
pos = snD.position/1000;
snD.stop();
} else {
soundSw = false;
this._parent;
sinMusic._alpha = 100;
snD.start(pos);
}
};
//создаем поле sounD и присоединяем к нему муз. файл из библиотеки
this.createEmptyMovieClip("sounD", this.getNextHighestDepth());
//
//создаем объект для звука Zvk
var snD:Sound = new Sound(sounD);
//
//прикрепляем звук Zvk к полю sounD
snD.attachSound("Zvk");
//
//устанавливаем для звука Zvk уровень громкости 90%
snD.setVolume(90);
snD.start();
//запускаем звук с начала, когда он доходит до конца
snD.onSoundComplete = function():Void {
snD.start();
};
При отключении звука происходят неприятные щелчки. Как бороться? :(
К вопросу прилагаю файл fla. 56 Килобайт. Выполнен для 8 флэш.
15052