Форум Flasher.ru
Ближайшие курсы в Школе RealTime
Список интенсивных курсов: [см.]  
  
Специальные предложения: [см.]  
  
 
Блоги Правила Справка Пользователи Календарь Сообщения за день
 

Вернуться   Форум Flasher.ru > Flash > ActionScript 1.0/2.0

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему Ответ
Старый 14.06.2014, 23:19
Vampika вне форума Посмотреть профиль Отправить личное сообщение для Vampika Найти все сообщения от Vampika
  № 1  
Ответить с цитированием
Vampika

Регистрация: Jun 2014
Сообщений: 1
По умолчанию Включение звука с определенного момента

Здравствуйте, мой вопрос вот в чем:
Есть мультик, в который вставлено много разных звуковых дорожек, идущих одна за другой. Есть кнопка "стоп", останавливающая видео и звук, и есть кнопка "начать", продолжающая видео с того же момента, где оно было остановлено. Как сделать так, чтобы звук тоже продолжался с того же момента, где был остановлен?

Старый 15.06.2014, 11:16
dark256 вне форума Посмотреть профиль Отправить личное сообщение для dark256 Посетить домашнюю страницу dark256 Найти все сообщения от dark256
  № 2  
Ответить с цитированием
dark256
 
Аватар для dark256

блогер
Регистрация: Apr 2008
Адрес: SPb
Сообщений: 3,718
Записей в блоге: 5
Отправить сообщение для dark256 с помощью ICQ Отправить сообщение для dark256 с помощью Skype™
start (Sound.start method)
public start([secondOffset:Number], [loops:Number]) : Void

Starts playing the last attached sound from the beginning if no parameter is specified, or starting at the point in the sound specified by the secondOffset parameter.

Availability: ActionScript 1.0; Flash Player 5

Parameters
secondOffset:Number [optional] - A parameter that lets you start playing the sound at a specific point. For example, if you have a 30-second sound and want the sound to start playing in the middle, specify 15 for the secondOffset parameter. The sound is not delayed 15 seconds, but rather starts playing at the 15-second mark.

loops:Number [optional] - A parameter that lets you specify the number of times the sound should play consecutively. This parameter is not available if the sound is a streaming sound.



position (Sound.position property)
public position : Number [read-only]

The number of milliseconds a sound has been playing. If the sound is looped, the position is reset to 0 at the beginning of each loop.

Availability: ActionScript 1.0; Flash Player 6

Example
See Sound.duration for a sample usage of this property.


duration (Sound.duration property)
public duration : Number [read-only]

The duration of a sound, in milliseconds.

Availability: ActionScript 1.0; Flash Player 6

Example
The following example loads a sound and displays the duration of the sound file in the Output panel. Add the following ActionScript to your FLA or AS file.

Код AS1/AS2:
var my_sound:Sound = new Sound();
my_sound.onLoad = function(success:Boolean) {
    var totalSeconds:Number = this.duration/1000;
    trace(this.duration+" ms ("+Math.round(totalSeconds)+" seconds)");
    var minutes:Number = Math.floor(totalSeconds/60);
    var seconds = Math.floor(totalSeconds)%60;
    if (seconds<10) {
    seconds = "0"+seconds;
    }
    trace(minutes+":"+seconds);
};
my_sound.loadSound("song1.mp3", true);

The following example loads several songs into a SWF file. A progress bar, created using the Drawing API, displays the loading progress. When the music starts and completes loading, information displays in the Output panel. Add the following ActionScript to your FLA or AS file.

Код AS1/AS2:
var pb_height:Number = 10;
var pb_width:Number = 100;
var pb:MovieClip = this.createEmptyMovieClip("progressBar_mc", this.getNextHighestDepth());
pb.createEmptyMovieClip("bar_mc", pb.getNextHighestDepth());
pb.createEmptyMovieClip("vBar_mc", pb.getNextHighestDepth());
pb.createEmptyMovieClip("stroke_mc", pb.getNextHighestDepth());
pb.createTextField("pos_txt", pb.getNextHighestDepth(), 0, pb_height, pb_width, 22);
 
pb._x = 100;
pb._y = 100;
 
with (pb.bar_mc) {
    beginFill(0x00FF00);
    moveTo(0, 0);
    lineTo(pb_width, 0);
    lineTo(pb_width, pb_height);
    lineTo(0, pb_height);
    lineTo(0, 0);
    endFill();
    _xscale = 0;
}
with (pb.vBar_mc) {
    lineStyle(1, 0x000000);
    moveTo(0, 0);
    lineTo(0, pb_height);
}
with (pb.stroke_mc) {
    lineStyle(3, 0x000000);
    moveTo(0, 0);
    lineTo(pb_width, 0);
    lineTo(pb_width, pb_height);
    lineTo(0, pb_height);
    lineTo(0, 0);
}
 
var my_interval:Number;
var my_sound:Sound = new Sound();
my_sound.onLoad = function(success:Boolean) {
    if (success) {
    trace("sound loaded");
    }
};
my_sound.onSoundComplete = function() {
    clearInterval(my_interval);
    trace("Cleared interval");
}
my_sound.loadSound("song3.mp3", true);
my_interval = setInterval(updateProgressBar, 100, my_sound);
 
function updateProgressBar(the_sound:Sound):Void {
    var pos:Number = Math.round(the_sound.position/the_sound.duration*100);
    pb.bar_mc._xscale = pos;
    pb.vBar_mc._x = pb.bar_mc._width;
    pb.pos_txt.text = pos+"%";
}
Соотв. в момент ПАУЗА запоминамем position и потом
Код AS1/AS2:
мой_звук.старт(my_position,0)
__________________
FLASHER.MAP SOUNDSTAGE / CS3 / AS2

Создать новую тему Ответ Часовой пояс GMT +4, время: 02:12.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


 


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


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