2013-02-10 4 views
0

애니메이션의 소리를 제어하기 위해 할당 된 1 개의 다시 시작 (onBtn) 및 1 개의 일시 중지 (offBtn) 버튼이 있습니다 ... 일시 중지 버튼은 정상적으로 작동하지만 다시 재생하면 ... 그것은작업 스크립트 3에 음악 다시 시작


import flash.events.Event; 
import flash.events.MouseEvent; 

onBtn.addEventListener(MouseEvent.CLICK, startMove); 
offBtn.addEventListener(MouseEvent.CLICK, stopMove); 

var resumeTime:Number = 0; 
var isPlaying:Boolean; 
var mySound:Sound = new MySong(); 
var channel1:SoundChannel = new SoundChannel(); 


onBtn.visible=false; 
isPlaying=true; 
channel1=mySound.play(); 


function stopMove(event:MouseEvent):void { 

    resumeTime=channel1.position; 
    channel1.stop(); 
    onBtn.visible =true; 
    offBtn.visible=false; 
    isPlaying=false; 
    stop(); 

} 

function startMove(event:MouseEvent):void { 
    channel1=mySound.play(resumeTime); 
    onBtn.visible=false; 
    offBtn.visible=true; 
    isPlaying=true; 
    play(); 
} 

답변

0

stopMove()에 다음 별도의 MovieClip에 애니메이션을 넣고 startMove() 당신이 play()를 호출하고 ... 처음부터 노래를 다시 시작하지가 가정하자 resumeTime이야에 ... 여기 내 코드입니다 stop() 그 기능은 MovieClip입니다. http://www.swfcabin.com/open/1360494138

그리고 코드의 변화 : 여기

는 작업 예제

import flash.events.Event; 
import flash.events.MouseEvent; 

stop(); //// 

onBtn.addEventListener(MouseEvent.CLICK, startMove); 
offBtn.addEventListener(MouseEvent.CLICK, stopMove); 

var resumeTime:Number = 0; 
var isPlaying:Boolean; 
var mySound:Sound = new MySong(); 
var channel1:SoundChannel = new SoundChannel(); 

onBtn.visible=false; 
isPlaying=true; 
channel1=mySound.play(0); 


function stopMove(event:MouseEvent):void { 
    resumeTime=channel1.position; 
    channel1.stop(); 
    onBtn.visible =true; 
    offBtn.visible=false; 
    isPlaying=false; 
    movieClip.stop(); //// Animation moved to movieClip 
} 

function startMove(event:MouseEvent):void { 
    if(resumeTime >= mySound.length) { 
    //// Go back to start when sound has finished playing 
    resumeTime = 0; 
    } 
    channel1=mySound.play(resumeTime); 
    onBtn.visible=false; 
    offBtn.visible=true; 
    isPlaying=true; 
    movieClip.play(); //// Animation moved to movieClip 
} 
+0

내 애니메이션로드 ... – mitche027

+0

이 해결 방법을 함께했다 때 음악이 재생되지 않습니다 그렇게한다면 그 문제와 첫 번째 게시물을 편집했습니다. – khailcs

관련 문제