擦洗孙子的时间线导致以前卸载的孙子swf的声音播放,干扰当前播放的孙子swf的声音

时间:2014-05-06 04:05:29

标签: actionscript-3 flash

我面临的问题是什么? 我有一个父文件。它按概述文件的名称加载子项。概述文件进一步加载许多(孙子)文件。我在父文件上有一个时间线擦除器。它可以擦除子文件和孙文件。问题是如果我加载孙子文件,卸载它。然后加载下一个孙子文件并擦除时间线,先前加载的孙子文件的声音开始播放。我怎么能阻止它?请帮助,我努力但我无法解决,我是业余的,没有正式的编程知识。感谢。

我提供了一个链接http://www.sendspace.com/filegroup/RA9RziNuDlC2MPj%2F11DoLLkW4A7ota%2B4KmmbltoalaeH%2FYEipSU22U2tlMBOBefBFc1RnhYpLCv3pRyAfFLxfA,以防有人想要查看代码。

重现错误:打开父文件。单击装甲链接,然后单击主页按钮以卸载它。现在,点击火炮链接,拖动洗涤器。

现在你将听到以前卸下的“装甲”孙子swf与该炮兵的声音一起播放的重叠声音。

     //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;

        }

0 个答案:

没有答案
相关问题