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

Help, how can I fix this error: TypeError: Error #2007: Parameter hitTestObject must be non-null.

New Here ,
May 28, 2023 May 28, 2023

Copy link to clipboard

Copied

TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at Function/Disparos2_fla:MainTimeline/preparen/Disparos2_fla:fuego()[Disparos2_fla.MainTimeline::frame1:107]

 

Code:

import flash.utils.Timer;
import flash.events.TimerEvent;
stop();
var VidaP=100;
VidaP:uint;
VidaPerro.text=VidaP.toString();
var fallos=0;
fallos:uint;
Fails.text=fallos.toString();
var Tiempo=61;
var timer:Timer= new Timer (1000,61);
timer.start();
timer.addEventListener(TimerEvent.TIMER, InicioT);
function InicioT (e:TimerEvent){
Tiempo --;
Segundos.text=Tiempo.toString();
}
timer.addEventListener(TimerEvent.TIMER,fin_del_juego);
function fin_del_juego(e:TimerEvent){
if(Tiempo==0){
gotoAndPlay("dos");
}
}
timer.addEventListener(TimerEvent.TIMER,derrota);
function derrota(e:TimerEvent){
if((fallos>=10)&&(Tiempo<59)){
gotoAndStop("dos");
}
}
timer.addEventListener(TimerEvent.TIMER,victoria);
function victoria(e:TimerEvent){
if((VidaP<1)&&(Tiempo<59)){
gotoAndStop("tres");
}
}
Mouse.hide();
stage.addChild(puaj);
puaj.mouseEnabled=false;
puaj.addEventListener(Event.ENTER_FRAME,prepara);
function prepara(event:Event){
puaj.x=stage.mouseX;
puaj.y=stage.mouseY;
}
 
var Lderechamira:Number=785;
var Lizquierdamira:Number=15;
var Larribamira:Number=18;
var Labajomira:Number=486.7;
 
addEventListener(Event.ENTER_FRAME,apunta);
function apunta(event:Event){
if(puaj.x<Lizquierdamira){
puaj.x=Lizquierdamira;
}
if(puaj.x>Lderechamira){
puaj.x=Lderechamira;
}
if(puaj.y<Larribamira){
puaj.y=Larribamira;
}
if(puaj.y>Labajomira){
puaj.y=Labajomira;
}
}
var Lam:lam=new lam;
Lam.x=400;
Lam.y=500;
addChild(Lam);
var gota:Gota=new Gota;
gota.x=400;
gota.y=500;
addChild(gota);
var RGP:rgp=new rgp;
RGP.x=400;
RGP.y=500;
addChild(RGP);
 
var puntos=0;
puntos:uint;
Aciertos.text=puntos.toString();
 
var velocidadgota:Number=25;
 
stage.addEventListener(MouseEvent.MOUSE_MOVE,apunten);
function apunten(e:MouseEvent){
var uno=mouseY-Lam.y;
var dos=mouseX-Lam.x;
var radian=Math.atan2(uno,dos);
var grados=radian/(Math.PI/180);
Lam.rotation=grados;
 
}
stage.addEventListener(MouseEvent.MOUSE_DOWN,preparen);
function preparen(pEvent){
var gota:Gota=new Gota;
gota.x=Lam.x;
gota.y=Lam.y;
gota.angleRadian=Math.atan2(mouseY-Lam.y,mouseX-Lam.x);
gota.addEventListener(Event.ENTER_FRAME,fuego);
addChild(gota);
function fuego(pEvent){
var gota=pEvent.currentTarget;
gota.x +=Math.cos(gota.angleRadian)*velocidadgota;
gota.y +=Math.sin(gota.angleRadian)*velocidadgota;
gota.rotation=gota.angleRadian*180/Math.PI;
var puag:Puag=new Puag();
if(gota.hitTestObject(MR)){
puag.play();
MR.x=Math.random()*799.75;
MR.y=Math.random()*3.35;
puntos ++;
Aciertos.text=puntos.toString();
}
//if(gota.x<0||gota.x>800||gota.y<0||gota.y>400){
//removeChild(gota);
//gota.removeEventListener(Event.ENTER_FRAME,preparen);
if(gota.hitTestObject(Perro)){
puag.play();
Perro.x=Math.random()*799.75;
Perro.y=Math.random()*3.35;
VidaP --;
VidaPerro.text=VidaP.toString();
}
}
}
 
var LderechaMR:Number=900;
var LizquierdaMR:Number=5;
var LabajoMR:Number=600;
var LarribaMR:Number=5;
 
var velocidadMR:Number=5;
stage.addEventListener(Event.ENTER_FRAME,MRmoviendose);
function MRmoviendose(event:Event){
if(MR.x<LizquierdaMR){
MR.x=LizquierdaMR;
}
if(MR.x>LderechaMR){
MR.x=LderechaMR;
}
if(MR.y<LarribaMR){
MR.y=LarribaMR;
}
if(MR.y>LabajoMR){
MR.y=LabajoMR;
}
MR.y+=velocidadMR;
if(MR.y>=491.7){
MR.y=Math.random()*3.35;
MR.x=Math.random()*799.75;
fallos ++;
Fails.text=fallos.toString();
}
}

 

TOPICS
ActionScript

Views

79

Translate

Translate

Report

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 ,
May 28, 2023 May 28, 2023

Copy link to clipboard

Copied

LATEST

make sure perro isn't null.

 

a sloppy way to do that:

 

if(perro){
if(gota.hitTestObject(perro){
//do whatever 

}

}

Votes

Translate

Translate

Report

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