Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

TypeError: Error #1009: Cannot access a property or method of a null object reference. at sound/onEFrame()

New Here ,
Oct 28, 2015 Oct 28, 2015

package  {

  import flash.display.MovieClip;

  import flash.events.Event;

  import flash.media.Microphone;

  import flash.display.StageAlign;

  import flash.display.StageScaleMode;

  public class sound extends MovieClip {

  private var _mic:Microphone;

  private var _sx:Number=0;

  private var sb:Number =_sx;

    private var soundboom:MovieClip;

  public function sound (){

  into();

  }

  private function into () :void{

  _mic = Microphone.getMicrophone();

  _mic.setLoopBack(true);

      addEventListener(Event.ENTER_FRAME, onEFrame);

  }

  private function onEFrame(evt:Event): void {

     _sx *=.9;

     _sx +=.4;

  _sx -=_mic.activityLevel * .05;

    soundboom.height -=_sx;

    soundboom.width -=_sx;

  if(soundboom.height > 81){

  _mic.setLoopBack(false);

  }

  if(soundboom.height>2){

  _mic.setLoopBack(true);

  }

  }

  }

}

package {

  import flash.display.MovieClip;

  import flash.events.Event;

  import flash.events.MouseEvent;

  import flash.media.Microphone;

  import sound;

  public class Mcass extends MovieClip {

  public var collisionHasOccured:Boolean = false;

  public var SoundB:sound;

  public var sb:Number;

  public var _mic:Microphone;

  public var _sx:Number;

  //public var soundboom:sound;

  public var soundboom:MovieClip;

  public function Mcass() {

  init();

  }

  public function init () :void {

  SoundB = new sound();

     soundboom = new sound();

  caveManB.rotate

  caveManB.x=-928.75;

  caveManB.y=312;

  addEventListener(Event.ENTER_FRAME, onFrame);

  trace (stage.stageWidth);

  trace (stage.stageHeight);

  this.Push.addEventListener(MouseEvent.MOUSE_DOWN,Pu);

  this.ADDMAN.addEventListener(MouseEvent.MOUSE_DOWN,ADD);

     this.Speed.addEventListener(MouseEvent.MOUSE_DOWN,sp);

  this.CMH.addEventListener(MouseEvent.MOUSE_DOWN,HM);

  this.$.addEventListener(MouseEvent.MOUSE_DOWN,NO);

  this.IB.addEventListener(MouseEvent.MOUSE_DOWN,BOX);

  this.Go.addEventListener(MouseEvent.MOUSE_DOWN,GO);

  }

  private function GO(evt:MouseEvent):void{

  Go.x=-928.75;

         caveManB.x=928.75;

     money.width=1;

  healthBar.height=202;

  healthBar2.height=199.5;

  win.x=-600;

  YL.x=-600;

  }

  private function BOX(evt:MouseEvent):void{

   SW.height--;

  

     }

  private function NO(evt:MouseEvent):void{

  SW.x=230;

  SW.y=249.3;

  SW.width =10;

  SW.height +=10;

  money.width=0;

  $.x =-600;

     }

  private function Pu(evt:MouseEvent):void{

  if(caveMan.hitTestObject(caveManB)){

  caveManB.y *= -0.1 + sb;

  caveManB.x *= -2 +sb;

   money.width +=10;

  }

  }

   private function stp(evt:MouseEvent):void{

   caveMan.x +=7 ;

     }

         private function HM(evt:MouseEvent):void{

  money.width  +=6;

  CavMH.height +=4 + sb;

  

  }

     private function sp(evt:MouseEvent):void{

    money.width +=4;

    caveManB.x +=10 + sb;

    }

    private function ADD(evt:MouseEvent):void{

  if(CavMH.height < 1){

  caveMan.x=60;

  caveMan.y=310;

  caveMan.vx;

  CavMH.height=42;

  }

  money.width +=2;

  caveMan.push

             caveMan.x = 60;

             caveMan.y = 310;

    

}

  private function onFrame(event:Event): void {

  soundboom.x = caveMan.x;

  soundboom.y = caveMan.y;

    if(caveMan.hitTestObject(player2)){

  healthBar2.height --;

  money.width --;

  if(! collisionHasOccured){

  collisionHasOccured =true;

  caveMan.x +=-2;

  ET.height--;

  this.Speed.removeEventListener(MouseEvent.MOUSE_DOWN,sp);

  this.CMH.removeEventListener(MouseEvent.MOUSE_DOWN,HM);

     }

  }else

        {

    player2.gotoAndStop (1);

    collisionHasOccured = false;

    caveMan.x +=2;

    }

   

  if(money.width >95) {

  //ET.height--;

  money.width= 95;

  this.Speed.removeEventListener(MouseEvent.MOUSE_DOWN,sp);

  this.CMH.removeEventListener(MouseEvent.MOUSE_DOWN,HM);

  this.Push.removeEventListener(MouseEvent.MOUSE_DOWN,Pu);

  this.ADDMAN.removeEventListener(MouseEvent.MOUSE_DOWN,ADD);

  _mic.setLoopBack(false);

  }if(money.width<94){

  _mic.setLoopBack(true);

  this.Push.addEventListener(MouseEvent.MOUSE_DOWN,Pu);

  this.ADDMAN.addEventListener(MouseEvent.MOUSE_DOWN,ADD);

     this.Speed.addEventListener(MouseEvent.MOUSE_DOWN,sp);

  this.CMH.addEventListener(MouseEvent.MOUSE_DOWN,HM);

  this.$.addEventListener(MouseEvent.MOUSE_DOWN,NO);

  this.IB.addEventListener(MouseEvent.MOUSE_DOWN,BOX);

     }

   if(caveMan.hitTestObject(caveManB)){

   caveMan.x  += 0;

       caveManB.x += 8;

   CavMH.height --;

  

  

  

   }else

   {

    caveManB.x +=-2;

   }

     if(CavMH.height < 1){

          caveMan.x =-100;

  caveMan.x += 0;

  }

  if(caveManB.hitTestObject(player1)){

      healthBar.height --;

  if(! collisionHasOccured){

  collisionHasOccured =true;

  caveManB.x += 9;

     }

  }else

        {

    player1.gotoAndStop (1);

    collisionHasOccured = false;

    caveManB.x +=-2;

}

                 if(healthBar.height < 1){

  addChild(YL);

  YL.x=181.2;

  YL.y=190;

  Go.x=482.5;

  this.Push.removeEventListener(MouseEvent.MOUSE_DOWN,Pu);

  this.ADDMAN.removeEventListener(MouseEvent.MOUSE_DOWN,ADD);

     this.Speed.removeEventListener(MouseEvent.MOUSE_DOWN,sp);

  this.CMH.removeEventListener(MouseEvent.MOUSE_DOWN,HM);

  this.$.removeEventListener(MouseEvent.MOUSE_DOWN,NO);

  this.CMH.removeEventListener(MouseEvent.MOUSE_DOWN,HM);

  this.IB.removeEventListener(MouseEvent.MOUSE_DOWN,BOX);

  

  } if(caveManB.hitTestObject(player2)){

          healthBar2.height --;

          money.width --;

  caveManB.x +=-2;

    if(caveMan.hitTestObject(caveManB)){

  CavMH.height =0;

  }

  

      

}

   if(ET.height<2)

  {

  caveManB.x=-815.4;

}if( caveManB.y < 312){

    caveManB.y += 5;

    caveManB.x +=9;

}if( caveManB.y > 312){

    caveManB.y = 312;

    caveManB.x;

}if(SW.height>2){

  ADDMAN.x = -600;

  IB.x=136;

  IB.y=178;

}else

{

      IB.x = -600;

   ADDMAN.x=171;

   $.x=385;

   $.y=-4.75;

}

if(healthBar2.height < 1)

  {

  win.x=181.2;

    win.y=190;

    Go.x=482.5;

  CavMH.height=0;

            this.Push.removeEventListener(MouseEvent.MOUSE_DOWN,Pu);

  this.ADDMAN.removeEventListener(MouseEvent.MOUSE_DOWN,ADD);

     this.Speed.removeEventListener(MouseEvent.MOUSE_DOWN,sp);

  this.CMH.removeEventListener(MouseEvent.MOUSE_DOWN,HM);

  this.$.removeEventListener(MouseEvent.MOUSE_DOWN,NO);

  this.CMH.removeEventListener(MouseEvent.MOUSE_DOWN,HM);

  this.IB.removeEventListener(MouseEvent.MOUSE_DOWN,BOX);

}if(_sx < 0){

  money.width +=20;

}function xVelocity (startPosition:Number, destination:Number , coeff:Number):Number {

  return (destination-startPosition)/coeff;

  }

}

}

}

TOPICS
ActionScript
243
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2015 Oct 28, 2015
LATEST

soundboom is not instantiated when your loop starts.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines