Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde a todos.
Estou com um problema em relação ao evento Event.SOUND_COMPLETE, fiz uma classe para tocar audios, mas o problema é que ele não me informa quando esse áudio já terminou de tocar, tentei adicionar um listner para me informar isso mas ainda sim ela não funciona, será que alguém pode me ajudar, abaixo segue a classe e a forma de utiliza-la
classe
package lmcosta.media
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import com.greensock.TweenMax
import com.greensock.easing.*
/**
* ...
* @author lmcosta
* @link www.lucasmarcal.com.br
* @version 1.0
*/
public class CreateMusic extends MovieClip
{
public var sound:Sound;
public var soundC:SoundChannel
public var musicStatus:Boolean = true;
public var posicao:Number = 0
public var volumeSound:Number
public var tocar:Boolean
public var loopSound:Number
public function CreateMusic(_str:String = "",_volume:Number = 0 , _tocar:Boolean = true, _loop:Number = 999)
{
this.soundC = new SoundChannel();
this.volumeSound = _volume;
this.tocar = _tocar;
this.loopSound = _loop;
this.sound = new Sound();
this.sound.load(new URLRequest(_str));
this.sound.addEventListener(Event.COMPLETE, this.onComplete)
//this.sound.addEventListener(Event.SOUND_COMPLETE , somCompleto)
this.soundC.addEventListener(Event.SOUND_COMPLETE , somCompleto);
}
public function somCompleto(e:Event):void
{
trace("Final do som")
}
private function onComplete(e:Event):void
{
trace("Carregou")
if (this.tocar == true)
{
this.soundC = this.sound.play(this.posicao, this.loopSound);
this.myVolume(this.volumeSound);
}
else
{
this.myVolume(this.volumeSound);
}
}
public function onPlay():void
{
this.soundC = this.sound.play(this.posicao, this.loopSound);
}
public function onStop():void
{
//this.posicao = this.soundC.position
this.soundC.stop();
}
public function myVolume(_volume:Number):void
{
var transform:SoundTransform = this.soundC.soundTransform;
transform.volume = _volume;
//this.soundC.soundTransform = transform;
TweenMax.to(this.soundC, 0.2, { volume:_volume, ease:Linear.easeNone } );
}
}
}
consumindo a classe
import lmcosta.media.CreateMusic;
var soundBt:CreateMusic;
function init ()
{
this.soundBt = new CreateMusic("NuvemCompleto.mp3", 1, true, 1);
}
init()
abraços.
Carregando comentários...