태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

ria/flex2010/04/22 14:13

flash.media.Sound 클래스를 보면,

play 메소드는 다음과 같이 정의 되어있다.

play (startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel
사운드를 재생하는 SoundChannel object를 새롭게 작성합니다.

loops에 0을 넣으면, 1번만 실행된다.

무한 루프를 돌게 하려면?

int.MAX_VALUE 를 넣어줌으로써 해결할 수 있다.

private function soundLoad():void
{
sound = new Sound();
//load complete
sound.addEventListener(Event.COMPLETE, function(event:Event):void{
readyStatus = true;
if( laterPlay ) playSound();
});
sound.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void{
trace( "IOErrorEvent.IO_ERROR: ", event.text );
});
var req:URLRequest = new URLRequest("./assets/sounds/error.mp3");
sound.load(req);
}
public function playSound():void
{
if( soundChannel ) return;
if( readyStatus ) {
laterPlay = false;
stopSound();
soundChannel = sound.play(0, int.MAX_VALUE);
} else {
laterPlay = true;
}
}
public function stopSound():void
{
if( soundChannel )
{
soundChannel.stop();
soundChannel = null;
}
}


참고

Posted by THLIFE.net

TRACKBACK http://thlife.net/trackback/994 관련글 쓰기

댓글을 달아 주세요