Search code examples
actionscript-3flash-cs6

Big bug on my .fla file, can't find any reason why it's not working


i have this .fla file that before isn't playing the sniper shot sound until you click the fire button. now it play 3-4 time while the game is playing without even playing the movieclip that is supposed to play with it.

PLEASE HELP!!!!

i've just encountered this and have checked every possible way i know to solve it. i don't know if it's a bug or not but i need to fix it right away or else this game, OUR THESIS, is done for! :(((((

link for download: name is sample_1, almost 8mb in size, saved on flash pro 6 format.

sample code as @musefan requested.

this is on the first stage. as you noticed it doesn't call for any music to be played.

function shootfired():void{
    if(sample_1.reloading == 0 && sample_1.GamePlaying == true){

            if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian1)){//if     fired on target
            if(mission.civillian1.currentLabel != "death"){ 
                mission.civillian1.gotoAndPlay("death");
                trace("target hit!");
            }
        }

        else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian2)){//if fired on target
            if(mission.civillian2.currentLabel != "death"){ 
                mission.civillian2.gotoAndPlay("death");
                trace("target hit!");
            }
        }

        else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian3)){//if fired on target
            if(mission.civillian3.currentLabel != "death"){ 
                mission.civillian3.gotoAndPlay("death");
                trace("target hit!");
            }
        }

        else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian4)){//if fired on target
            if(mission.civillian4.currentLabel != "death"){ 
                mission.civillian4.gotoAndPlay("death");
                trace("target hit!");
            }
        }

        else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian5)){//if fired on target
            if(mission.civillian5.currentLabel != "death"){ 
                mission.civillian5.gotoAndPlay("death");
                trace("target hit!");
            }
        }

        else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian6)){//if fired on target
            if(mission.civillian6.currentLabel != "death"){ 
                mission.civillian6.gotoAndPlay("death");
                trace("target hit!");
            }
        }

        else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian7)){//if fired on target
            if(mission.civillian7.currentLabel != "death"){ 
                mission.civillian7.gotoAndPlay("death");
                trace("target hit!");
            }
        }

        else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.target1)){//if fired on target
            if(mission.target1.currentLabel != "death"){
                mission.target1.gotoAndPlay("death");
            }
        }

        else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.target2)){//if fired on target
            if(mission.target2.currentLabel != "death"){
                mission.target2.gotoAndPlay("death");
            }
        }
        MC_SniperGun.MC_Sniper.gotoAndPlay(2);
    }
}

next this is the code for the snipergun again no music is call to be played.

import flash.events.*;
import flash.geom.Rectangle;

SniperFunction();
function SniperFunction():void{

    stop();
    MC_SniperGun.addEventListener(TouchEvent.TOUCH_BEGIN, Tdrag);
    MC_SniperGun.addEventListener(TouchEvent.TOUCH_END, Tdrop);

    function Tdrag(e:TouchEvent){
        MC_SniperGun.MC_Sniper.startTouchDrag(e.touchPointID, false, boundArea);
    }
    function Tdrop(e:TouchEvent) { 
        MC_SniperGun.MC_Sniper.stopTouchDrag(e.touchPointID); 
    }

    MC_SniperGun.addEventListener(MouseEvent.MOUSE_DOWN, drag);
    MC_SniperGun.addEventListener(MouseEvent.MOUSE_UP, drop);

    function drag(event:MouseEvent):void {
        MC_SniperGun.MC_Sniper.startDrag(false,boundArea);
    }

    function drop(event:MouseEvent):void {
        MC_SniperGun.MC_Sniper.stopDrag();
    }
    gotoAndPlay("mission" + sample_1.MissionNumber);
}

and lastly the codes from movieclip that contains the animation of the snipergun.

SniperShot();
function SniperShot():void{
    sample_1.reloading = 1;
    trace("Sniper Shot");
}

the movieclip that contains the animation of the snipergun has a frame that has a sound property that when that particular frame is being played the sniper music file will be played but when i play that game the animation doesn't play but the sniper music files play for 3-4 time without pressing the fire button.


Solution

  • Replace my.mp3 with the sound that is saved to your library

    var snd:Sound = new Sound();
    snd.load(new URLRequest("my.mp3"));
    snd.play();
    

    Then just make it go to the sniper animation