Actionscript 3 擦洗孙子的时间线会导致先前卸载的孙子swf的声音播放,干扰当前播放孙子swf的声音
我面临什么问题? 我有一个父文件。它按概述文件的名称加载子级。概述文件进一步加载许多孙子文件。我在父文件上有一个时间轴清理器。它同时清理子文件和孙子文件。问题是,如果我加载孙子文件,则卸载它。然后加载下一个孙子文件并拖动时间轴,先前加载的孙子文件的声音开始播放。我怎样才能阻止它??请帮助,我已经努力了,但我不能解决,我是业余爱好者,没有正式的编程知识。谢谢 我提供了一个链接,以防有人想看到代码 要复制错误,请打开父文件。点击装甲链接,然后点击主页按钮卸载它。现在,点击炮兵链接,拖动洗涤器 现在,你将听到之前卸载的“装甲”孙子swf的重叠声音和炮兵swf的声音一起播放Actionscript 3 擦洗孙子的时间线会导致先前卸载的孙子swf的声音播放,干扰当前播放孙子swf的声音,actionscript-3,flash,Actionscript 3,Flash,我面临什么问题? 我有一个父文件。它按概述文件的名称加载子级。概述文件进一步加载许多孙子文件。我在父文件上有一个时间轴清理器。它同时清理子文件和孙子文件。问题是,如果我加载孙子文件,则卸载它。然后加载下一个孙子文件并拖动时间轴,先前加载的孙子文件的声音开始播放。我怎样才能阻止它??请帮助,我已经努力了,但我不能解决,我是业余爱好者,没有正式的编程知识。谢谢 我提供了一个链接,以防有人想看到代码 要复制错误,请打开父文件。点击装甲链接,然后点击主页按钮卸载它。现在,点击炮兵链接,拖动洗涤器 现在,
//CUSTOM event sent by child swf, once grandchild swf is loaded
stage.addEventListener("playGrandchildScrubber", disableScrubberF);
function disableScrubberF(e:Event):void
{
var grandChildMC:MovieClip = thisMC.myLoader.content;
var actualTrackLengthGC : Number = ((scrubberMC.scrubBarMC.width) - (scrubberMC.scrubHandleMC.width));
var animLengthGC : int = grandChildMC.totalFrames;
var leftBoundGC : Number = scrubberMC.scrubBarMC.x;
var rightBoundGC : Number = scrubberMC.scrubBarMC.x + actualTrackLengthGC;
var dragBoundGC : Rectangle = new Rectangle(leftBoundGC, scrubberMC.scrubHandleMCGC.y, actualTrackLengthGC, 0);
var calcWidthGC : Number = actualTrackLength/grandChildMC.totalFrames;
//sets the value of boolean "grandChildSwfLoaded" to true, indicating gradchild swf has been loaded.
grandChildSwfLoaded = true;
//Hides scrubberhandle, totoal time and current time, fill of CHILD TIMELINE SCRUBBER. GRANDCHILD TIMELINE SCRUBBER HANDLE
//CURRENT TIME AND TOTOAL TIME BECOME VISIBLE.
currentTimeGC.visible= true;
totalTimeGC.visible=true;
totaltime.visible = false;
currentTime.visible = false;
scrubberMC.scrubHandleMCGC.visible = true;
scrubberMC.scrubHandleMC.visible = false;
scrubberMC.fill_mcGC.visible = true;
scrubberMC.fill_mc.visible = false;
//CODE FOR CURRENT TIME OF GRAND CHILD SWF
var totalSeconds = Math.floor(grandChildMC.totalFrames / 24);
var input = totalSeconds;
var totalAnimTime = (input > 3600 ? Math.floor(input/3600) + ':':'')
+(input%3600 < 600 ? '0':'')+Math.floor(input%3600/60)+':'
+(input%60 < 10 ? '0':'')+input%60;
totalTimeGC.text = " / " + totalAnimTime;
//thisMC refers to child swf, i.e., overview swf
thisMC.stop();
animationPlaying = false;
grandChildMC.play();
grandchildAnimationPlaying = true
scrubberMC.addEventListener(Event.ENTER_FRAME, updateScrubberGC);
scrubberMC.scrubHandleMCGC.x = leftBoundGC;
scrubberMC.scrubHandleMCGC.buttonMode = true;
scrubberMC.scrubHandleMCGC.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseEventsGC);
function handleMouseEventsGC(evt:MouseEvent):void
{
switch(String(evt.type)) {
//following work is done when you hold the mouse down.
case MouseEvent.MOUSE_DOWN:
removeEventListener(Event.ENTER_FRAME, playScrubGC);
scrubberMC.removeEventListener(Event.ENTER_FRAME, updateScrubberGC);
scrubberMC.scrubHandleMCGC.startDrag(false, dragBoundGC);
stage.addEventListener(MouseEvent.MOUSE_UP, handleMouseEventsGC);
grandChildMC.addEventListener(Event.ENTER_FRAME, scrubMovieGC);
if (grandchildAnimationPlaying) grandChildMC.stop();
break;
case MouseEvent.MOUSE_UP:
scrubberMC.scrubHandleMCGC.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_UP, handleMouseEventsGC);
grandChildMC.removeEventListener(Event.ENTER_FRAME, scrubMovieGC);
if (grandchildAnimationPlaying) grandChildMC.play();
grandchildAnimationPlaying = true;
scrubberMC.addEventListener(Event.ENTER_FRAME, updateScrubberGC);
pp.play_btn.visible = false;
pp.pause_btn.visible = true;
if (grandChildMC.currentLabel == "swfComplete") {
//disable pause button on last frame
disablePause_mc.visible=true;
} else {
//enable pause button on all frames except last frame
disablePause_mc.visible=false;
}
if (grandChildMC.currentFrame==grandChildMC.totalFrames) {
grandChildMC.stop();
}else{
grandChildMC.play();
}
if (grandChildMC.currentFrame > grandChildMC.totalFrames) {
scrubberMC.removeEventListener(Event.ENTER_FRAME, updateScrubberGC);
}
break;
}
}
function scrubMovieGC(evt:Event):void
{
scrubberMC.removeEventListener(Event.ENTER_FRAME, updateScrubberGC);
var scrubPosGC : int = scrubberMC.scrubHandleMCGC.x;
var calcWidthGC : Number = actualTrackLengthGC/grandChildMC.totalFrames;
var gotoFrameGC : int = Math.ceil(scrubPosGC /calcWidthGC);
thisMC.stop()
grandChildMC.gotoAndStop(gotoFrameGC);
}
function updateScrubberGC(evt:Event):void
{
var percentGC : Number = ((grandChildMC.currentFrame)/(grandChildMC.totalFrames));
scrubberMC.scrubHandleMCGC.x = percentGC * actualTrackLengthGC;
scrubberMC.fill_mcGC.width = percentGC * actualTrackLengthGC;
//CODE FOR CURRENT TIME OF GRAND CHILD SWF
var currentSeconds = Math.floor(grandChildMC.currentFrame/24);
var CurrentInput = currentSeconds;
var timeElapsed = (CurrentInput > 3600 ? Math.floor(CurrentInput/3600) + ':':'') //hours
+(CurrentInput%3600 < 600 ? '0':'')+Math.floor(CurrentInput%3600/60)+':' //minutes
+(CurrentInput%60 < 10 ? '0':'')+CurrentInput%60; //seconds
currentTimeGC.text = timeElapsed;
}
addEventListener(Event.ENTER_FRAME, playScrubGC);
function playScrubGC(event:Event):void{
var percentGC : Number = ((grandChildMC.currentFrame)/(grandChildMC.totalFrames));
var actualTrackLengthGC : Number = ((scrubberMC.scrubBarMC.width) - (scrubberMC.scrubHandleMCGC.width));
scrubberMC.scrubHandleMCGC.x = percentGC * actualTrackLengthGC;
scrubberMC.fill_mcGC.width = percentGC * actualTrackLengthGC;
var scrubPosGC : int = scrubberMC.scrubHandleMCGC.x;
var calcWidthGC : Number = actualTrackLengthGC/grandChildMC.totalFrames;
var gotoFrameGC : uint = Math.round(scrubPosGC/calcWidthGC);
//CODE FOR CURRENT TIME OF GRAND CHILD SWF
var currentSeconds = Math.floor(grandChildMC.currentFrame/24);
var CurrentInput = currentSeconds;
var timeElapsed = (CurrentInput > 3600 ? Math.floor(CurrentInput/3600) + ':':'') //hours
+(CurrentInput%3600 < 600 ? '0':'')+Math.floor(CurrentInput%3600/60)+':' //minutes
+(CurrentInput%60 < 10 ? '0':'')+CurrentInput%60; //seconds
currentTimeGC.text = timeElapsed;
}
}
stage.addEventListener("enableChildScrubberDisableGrandchildScrubber", enableScrubberF);
function enableScrubberF(e:Event):void
{
currentTimeGC.visible= false;
totalTimeGC.visible=false;
totaltime.visible = true;
currentTime.visible = true;
scrubberMC.scrubHandleMCGC.visible = false;
scrubberMC.scrubHandleMC.visible = true;
scrubberMC.fill_mcGC.visible = false;
scrubberMC.fill_mc.visible = true;
}
删除时间线编码周期。对不起,我并没有理解你们,若我并没有在时间线上写代码,那个么我应该在哪里写代码?你是在建议把actionscript文件分开吗?是的,没错。请看,时间线代码在初始化其变量方面有其技巧,而且您在某个帧上编写的所有代码在您转到该帧时都会执行,无论是正常播放还是gotoAndStop调用。这会使您的变量重新初始化,包括额外的加载请求,并且还会重建显示中的其他对象,这会导致各种错误。没有任何时间线编码的单独AS3文件更可靠,因为您完全控制代码流和变量处理。还需要考虑将MCS转换为精灵,如果需要持久性的话,让那些动画化的MCS作为控件精灵的孩子,这样他们的动画就不会干扰变量分配和其他代码流,也就是说将代码与视觉分离开来。请大家帮忙。SoundMixer.stopAll将无法工作,因为它会静音所有声音,包括当前播放孙子的声音。声音变换也是如此。知道是什么导致了这个问题吗。根本原因是什么?