Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 基于定时器的Actionscript循环声音_Actionscript 3_Flash - Fatal编程技术网

Actionscript 3 基于定时器的Actionscript循环声音

Actionscript 3 基于定时器的Actionscript循环声音,actionscript-3,flash,Actionscript 3,Flash,我试图在Flash CC中根据时间循环声音 基本上我希望声音循环,只要时间大于0 这就是我到目前为止提出的,似乎只是锁定了调试器 import flash.utils.Timer; import flash.events.TimerEvent; import flash.events.Event; var s:soundEffect = new soundEffect(); var time = 15; var myTimer:Timer = new Timer(1000,15) myTimer

我试图在Flash CC中根据时间循环声音

基本上我希望声音循环,只要时间大于0

这就是我到目前为止提出的,似乎只是锁定了调试器

import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.Event;
var s:soundEffect = new soundEffect();
var time = 15;
var myTimer:Timer = new Timer(1000,15)
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, timerHandle)

function timerHandle(e:TimerEvent){
txt_Timer.text = time;
while(time>0){
    s.play()}
    time --;
}

循环是内置的特性

//Simple loop
var sound:SoundEffect = new SoundEffect();
var playChannel:SoundChannel = sound.play(0, int.MAX_VALUE);

//Finish loop after 1 second
var sound:SoundEffect = new SoundEffect();
var playChannel:SoundChannel = sound.play(0, int.MAX_VALUE);
var timer:Timer = new Timer(1000, 1); //Stop loop after 1 second
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onCompleteTimer);
timer.start();

function onCompleteTimer(e:TimerEvent):void {
    playChannel.stop();
}