5 Replies Latest reply on Oct 23, 2012 3:05 PM by kglad

    Crosshair not over enemies, sound delayed?

    gabessdsp

      http://gabessdsp.hostzi.com/flash_projects/agent_hunter/AgentHunting.swf

       

      That is where you can see and listen to exampels of my problem. When you start off there's a good couple of seconds before the music starts for the title and after you hit play. When you fire a bullet there's a very minute but noticable pause before you hear the gunshot go off as well. How can I fix that problem? this is what I'm doing with my sounds:

       

      var gameSounds:Sound = new Sound(new URLRequest("inGame.mp3"));

      gameSounds.play();

       

      and how come the crosshair won;t fire if it's located above a bullet object, and for some reason it's hidden behind the enemies and won;t fire if under them either. Here is my main code for that frame(take note I am using classes but there is nothing in the classes file yet):

       

      var gameSounds:Sound = new Sound(new URLRequest("inGame.mp3"));

      gameSounds.play();

      var gunShotSound:Sound = new Sound(new URLRequest("gunshot.mp3"));

       

       

      import flash.events.MouseEvent;

      import flash.display.MovieClip;

      import flash.geom.Point;

       

       

      stop();

       

       

      Mouse.hide();

       

       

       

       

      main_crosshair.startDrag(true);

      main_crosshair.addEventListener(MouseEvent.MOUSE_DOWN, crosshairFX);

       

       

      function crosshairFX (e:MouseEvent):void{

                gunShotSound.play();

                var projectile:bullet = new bullet();

       

                projectile.x = parent.mouseX;

                projectile.y = parent.mouseY;

       

                addChild(projectile);

                main_crosshair.gotoAndPlay(3);

       

      }

       

       

       

       

      for (var i = 0; i < 10; i++){

                var enemies:enemy = new enemy();

                enemies.x = stage.stageWidth * Math.random();

                enemies.y = stage.stageHeight * Math.random();

                addChild(enemies);

      }