error #2007
hi , how all? hope fine...
iam trying make game when object hit object delete object these errors
typeerror: error #2007: parameter hittestobject must non-null.
@ flash.display::displayobject/_hittest()
@ flash.display::displayobject/hittestobject()
@ main/onenterframe()
and here class
(iam sure problem class because closed classes except 1 )
package {
import flash.display.movieclip;
import flash.events.event;
public class main extends movieclip {
public function main() {
addeventlistener(event.added_to_stage,onaddedtostage)
}
public function onaddedtostage(event:event):void
{
addeventlistener(event.enter_frame,onenterframe )
}
public function onenterframe (event:event)
{
if (hero.hittestobject(bat1) && (bat1) && (bat1.stage))
{
healthbar1.width -=1
trace("hhh")
}
if (healthbar1.width >= 80 && healthbar1.width <= 100 ){
zelda1.gotoandplay(1)
}
if (healthbar1.width >= 60 && healthbar1.width <= 80){
zelda1.gotoandplay(2)
}
if (healthbar1.width >= 40 && healthbar1.width <= 60){
zelda1.gotoandplay(3)
}
if (healthbar1.width >= 20 && healthbar1.width <= 40){
zelda1.gotoandplay(4)
}
if (healthbar1.width >= 0 && healthbar1.width <= 20){
zelda1.gotoandplay(5)
}
if (hero.hittestobject(portal2)){
var map2:map2 = new map2
addchild(map2)
if(map1.stage){
removechild(map1)
}
}
if (hero.hittestobject(portal3) && (portal3) && (portal3.stage) && (bat1)){var map4:background = new background();
if(bat1){
removechild(bat1)
bat1.removeeventlistener(event.enter_frame, onenterframe); // doesn't need done unless added listener outside bat1 classs
bat1 = null;
removechild(portal3)
portal3 = null
}
}
}
}
}
i talked problem before in discuss
and project image here
i tried alot check if statement bat1 object error still.
thank you
you're not following directions. use code suggested.
using
if(hero.hittestobject(bat1)&&bat1)
is not same as
if(bat1){
if(hero.hittestobject(bat1))
More discussions in ActionScript 3
adobe
Comments
Post a Comment