2012-09-05 1 views
0

저는 Actionscript 3를 처음 사용하고 Flash CS6을 사용합니다. - 난 재생하려는음악 재생을위한 mc 재생/일시 중지 단추를 전환 할 수 없습니다. 라이브러리에 내보내기 위해 연결된 음악 (AS)

은/countrymeadow라는 이름의

-countrymeadow.mp3이 도서관에서 액션 스크립트 (countrymeadow)에 대한 수출을 위해 연결되어 20 분 MP3를 일시 중지합니다.

  • 재생 일시 중지 버튼은 버튼 내부의 첫 번째 프레임 (재생) 및 10 번째 프레임 (일시 중지)에서 중지됩니다.

  • AS3는 아래에 있지만 작동하지 않습니다. mc playpause 버튼은 테스트했을 때 '재생'과 '일시 중지'를 반복적으로 전환하므로 아무 소리도 재생되지 않습니다.

도움을 주시면 감사하겠습니다.

//set appearance of button, mode to true 
playpause_mc.gotoAndStop("play"); 
playpause_mc.buttonMode = true; 

//sound is stopped after loaded 
var isPaused:Boolean = true; 

//saves current position of sound 
var currPos:int = 0.00; 

var theSound:countrymeadow = new countrymeadow(); 
snd.play(); 

var soundCnl:SoundChannel = new SoundChannel(); 

//Listener updates after sound loads, and stops   soundtheSound.addEventListener(Event.COMPLETE, onComplete, false, 0, true); 
function onComplete(evt:Event):void { 
    //Stop loaded sound 
    soundCnl.stop(); 
} 


// movie clip button control 
playpause_mc.addEventListener(MouseEvent.CLICK, clickHandler); 
function clickHandler(event:MouseEvent):void { 

    if(isPaused){ 
     //change state to playing, and play sound from position 
     isPaused = false; 
     soundCnl = theSound.play(currPos); 

     //reverse the appearance of the button 
     playpause_mc.gotoAndStop("pause") 

     //if sound completes while playing, run function 
     soundCnl.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler); 

    }else{ 
     //it's playing, so save position and pause sound 
     currPos = soundCnl.position; 
     isPaused = true; 
     soundCnl.stop(); 

     //change the appearance of the buttons 
     playpause_mc.gotoAndStop("play") 
    } 
} 

답변

0

사운드 채널 positionNumber입니다. 범위는 0에서 1까지입니다. 그러나 변수는 int입니다. int은 부동 소수점 유형이 아닙니다. int 유형으로 명시 적으로 선언했기 때문입니다. 부동 소수점 초기화로 바뀌었을 때에도 int 유형으로 변환하십시오.

enter image description here

이 다음해야한다. clickHandler 함수 일부가 수정되었습니다.

var currPos:Number = 0.0; 

soundCnl.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler); 
function clickHandler(event:MouseEvent):void { 

    if(isPaused){ 
     //change state to playing, and play sound from position 
     isPaused = false; 
     soundCnl.play(currPos); 

     //reverse the appearance of the button 
     playpause_mc.gotoAndStop("pause") 

    }else{ 
     //it's playing, so save position and pause sound 
     currPos = soundCnl.position; 
     isPaused = true; 
     soundCnl.stop(); 

     //change the appearance of the buttons 
     playpause_mc.gotoAndStop("play") 
    } 
} 

테스트 코드 :

var n:int = 0.0; 

n = 0.5; 

trace("n: " + n); //you may expected 0.5, but return 0. 
+0

감사 어쨌든,하지만 난이 교체되어있어 이해하지 않습니다. 내 코드에서 무엇을 지켜야하며 무엇을 바꿀 수 있습니까? 그보다 더 좋은 예를 더 잘 보여줄 수 있습니까? 재 : 수정 내 코드가 포함되어 있습니다 ... – user1632767

관련 문제