Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   Повторение звука (http://www.flasher.ru/forum/showthread.php?t=136615)

greatilya 21.02.2010 10:23

Повторение звука
 
Имеется код:
Код AS3:

var snd:Sound = new Sound();
snd.load(new URLRequest("sound.mp3"));
var channel:SoundChannel = new SoundChannel();
snd.addEventListener(Event.COMPLETE, onLoadComplete, false, 0, true);
snd.addEventListener(Event.SOUND_COMPLETE, onSoundComplete, false, 0, true);
 
function onLoadComplete(evt:Event):void {
        //var localSnd:Sound = evt.target as Sound;
        channel = snd.play();
}
function onSoundComplete(evt:Event):void
{
//channel.stop();
channel = snd.play();
}

Не могу понять почему не происходит повторение музыки.

Уже ошибочно писал в другую тему: http://flasher.ru/forum/showthread.php?t=136595

Заранее спасибо.

E-mail 21.02.2010 11:51

Событие soundComplete отправляет объект класса SoundChannel, а не Sound

greatilya 21.02.2010 12:25

Не могу понять что требуется, так не получается если заменть на это:
Код AS3:

channel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);

Если не сложно дайте более подробные комментарии. еще раз извините.

E-mail 21.02.2010 21:06

Код AS3:

package 
{
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.events.Event;
        import flash.net.URLRequest;
 
        public class MyClass
        {
                public var snd:Sound;
                public var channel:SoundChannel;
 
                public function MyClass()
                {
                        snd = new Sound();
                        snd.addEventListener(Event.COMPLETE, completeHandler);
                        snd.load(new URLRequest("sound.mp3"));
                }
                private function completeHandler(evt:Event):void
                {
                        channel = snd.play();
                        channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
                }
                private function soundCompleteHandler(evt:Event):void
                {
                        channel.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
                        channel = snd.play();
                        channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
                }
        }
}

как-то так

greatilya 22.02.2010 06:27

Огромное спасибо! :)
Сам бы не догадался...


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

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