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;
}
}
참고
'ria > flex' 카테고리의 다른 글
| [Flex] Label 에 backgroundColor 변경하기, (0) | 2010/05/06 |
|---|---|
| [Flex, AIR] Sound 무한 loop (0) | 2010/04/22 |
| [Flex] Output folder를 변경할수 없을때,,,조치 방법 (0) | 2010/02/23 |
| [Flex] Convert String to Date (3) | 2009/06/25 |
| AdvancedDataGrid Sort Icon 안보이기 (0) | 2009/06/02 |
| Flex 에서 SecureAMF / HTTPS 사용하기 (0) | 2009/04/13 |




댓글을 달아 주세요