ActionScript 3.0 :: Flash - Game HitTestObject Error?
Aug 17, 2011
I'm new to ActionScript but I've been following Lynda tutorials and tried to tailor them to my game. I simply want to make my character at the top of the screen shoot at enemies below. The error I'm getting when I press the shoot button is "Parameter hitTestObject must be non-null." I've read some other forum posts on this error for ideas but still can't seem to make mine work.
Basically every functions without hitTests are removed without errors, but all the ittestobjects that i have in the end game frame says that it cannot acess a nullhitTestObject. One of the hitTests i have is this one:
if (this.hitTestObject(_root.anulpowerups)) { this.parent.removeChild(this); removeEventListener(Event.ENTER_FRAME, checkCollision);
Code is working but i am getting the following error and it is driving me insane:
TypeError: Error #2007: Parameter hitTestObject must be non-null. at flash.display:isplayObject/_hitTest() at flash.display:isplayObject/hitTestObject() at PlatformGame/checkCollisions() at PlatformGame/gameLoop()
Here is my Frankenstein code...i just need it working. Error happens when I remove the numOfKeys-- where I examine the level. Had to remove some code because of length when posting here on FK.
I'm making target shooting game and the hitTestObject not working its located in the function collision detection below in my code: import fl.motion.MotionEvent; import flash.events.MouseEvent; var xSwitch:Array = new Array ; var count:Number = 120; var seconds:Number = 0; var minutes:Number = 0; [Code] .....
I am developing a target game with Touch Event so that you can use-up all your fingers, but I can't remove the enemy from the stage. I'll paste the code
public function onTouchBegin(e:TouchEvent):void { var dot:Sprite = this.getCircle();
I am working on a fairly simple drag and drop based Flash piece and I have come across an Output Error which I was hoping somebody could give me a better understanding of.As a very brief back-story to my problem, I have two borders on both the far left and right of my movie and the alpha is set to 0 on both of these MovieClips; now I have labels within the movie and I am using the hitTestObject command with an IF statement stating that should the label_mc hit either border1_mc or border2_mc on Mouse Move then execute some code; my problem is that in my Output panel I have now received the error:
TypeError: Error #2007: Parameter hitTestObject must be non-null.
I am not sure about this particular error and would be interested if anybody had any ideas on a fix or solution as I want to understand what is going on with this; I read around some forums which said that when you use hitTestObject the console is listening out for the intersect and that if you move on to different labels later in the movie if the MovieClips you intend to hit aren't present throughout the piece it may cause this error (but I might and probably am wrong).
I don't get any compiler errors, but I do however get the message: TypeError: Error #1006: hitTestObject is not a function. does anyone no the common cause of this? If you need me to post my code I can do that to.
I've posted a former thread where i was struggling to get to the next frame. I've now managed to do so but my character wont move when i get to the next frame. this is the code i am using:
I'm currently in the process of making a flash video game where you fly around as a pigeon (named Barnaby) in a park and poop on people's heads while dodging obstacles like balloons and stuff . Right now, though, I can't seem to get rid of this dang error "Error #1009: Cannot access a property or method of a null object reference."[code]...
ame_Manager.as= this manages the creation of balloons, players and collisionsBalloon.as= This is the balloon classPlayer.as=This is the player classThe Game Manager class will pass stage to the balloon and player classes and create them. I add these two in the Game Manager class.In the balloon class i add all the balloons in an balloon array.Now when i run the code i am unable to check for collisions as nothing happens when the player and balloon collides. and i get a child must be a caller of the display object when i ry to remove the balloons after they have crossed the stage.I have been trying to make it work for a long time a the game is very very simple.in the Object Oriented way of designing this simple game as i think that is where my error might be.I will post the code for these belowGame Manager.as
Code: public class GameManager extends MovieClip{ public var backGround:BackGround;
How to solve this error as it will keep popping out whenever I click on the play button of the game I'm creating. TypeError: Error #1009: Cannot access a property or method of a null object reference. at index_fla::MainTimeline/frame2() at flash.display::MovieClip/gotoAndStop() at index_fla::MainTimeline/clickPlay()
Trying to do hitTestObject on instances that are dynamically placed on the stage. Receiving an error:
TypeError: Error #2007: Parameter hitTestObject must be non-null. at flash.display::DisplayObject/_hitTest() at flash.display::DisplayObject/hitTestObject()
I had a problem with my hitTestObject collision detection a couple of days ago which has since been fixed (How can I solve my hitTestObject Collision Null Object Ref Error) with the help of you folks. My problem now is as such: When my "enemy.hit" comes into contact with "player.hit" it registers as a hit - this is good. When my "building.collide" comes into contact with "player.hit" it registers as a hit - this is good.
However, when my "building.collide" comes into contact with my "enemy.hit" it does not register, but sometimes it does register even though the only enemy on-screen is many pixels away from it - as if either the building or enemy "hitBox" is somewhere other than directly on the graphic(MovieClip in this case).
I'm making a simple snake game in as3. the problem I'm having is that the stroke on elements slightly overlap thus when the snake passes by the apple in an adjacent square it triggers hit test object. If i reduce the size or stroke of either the snake or the apple then they dont properly line up to the grid. is there a way i can use hittestobject but reduce the area of the object that will trigger it. ie only trigger if it hits the center of the object?
//this will hit when snake is adjacent due to overlapping strokes if(snake.hitTestPoint(apple.x,apple.y,true)) {[code]............
when I traced the values for the bottom code the values are what would be expected but some reason hitTestPoint wont trigger. strangely if I do + 1 it will still work but because the stroke is 2 i need at least +3. If i set apple.x+n as a variable and use the variable in hitTestPoint it wont trigger. also on all cases where it does not trigger i get no errors and all trace values are what you would suspect...
I am placing my code within frames and using the code below to hit test an object. After the animated object leaves the stage, the hit test starts getting errors because it is now looking for an object that isn't there. NULL
Code: var o1:MovieClip; o1.addEventListener(Event.ENTER_FRAME, o1hit); function o1hit(Event) {
[Code]...
So the question is: How can I get the Hit Test to stop after a certain frame? Or does it have to do with the EventListener?
Is there any other function similar to 'hitTestObject'. Am having problem with this function, b'coz it checks the collision on a box around that object. I want to find the actual collision with the object.
I'm creating a game at the moment for my university course and it involves the player character jumping on top of boxs twice to break them as opposed to just once.What would be the most efficient/simple way of writing this in Actionscript 3.
i keep getting this error, and when i play my game when u punch or use the fist the grannys stop moving, and disapeer after the first punch when i just walk up to them without even having to punch.and then all the 1009 errors start flying for my checkFront() and grannyMove()ill post all the methods involving the problem
Code: public function grandmaSpawn(event:Event):void { if(spawn == 1){ for (var i:int = 0; i<=4; i++){
I have a bullet object and a boulder object (both movieclips originating from JPEGs) in my AS3 game. The trouble I'm having is with hitTestObject for the collision detection, as it's taking in to account the transparent areas and basing the collision on the bounding boxes surrounding the movieclips. This is a problem because the collisions are not accurate and if the bullet (long and thing line shaped) is at an angle...the bounding box is quite large around it...and it's "colliding" with the boulder even though it's visibly many pixels away. Is there a way to detect MovieClip collisions that ignore transparent areas?
I am thinking of developing of a game like this: [URL]... Do you have any idea - by which game engine I may develop this type of games? I am not sure whether I have to use any 3d physics engine? I think JiglibFlash may be useful, but I am not sure.
In my basic platform game I have a "hero" that can walk and jump on the "ground." There is also a door to the next scene, which is the next level.The first scene works fine, but "TypeError: Error #1006: value is not a function. at Charles3_fla::MainTimeline/frame1()" pops up once in the output. It works however, and I'm not worried about it. The second I go throught the door though, Scene 2 opens, but then starts flashing as "TypeError: Error #1009: Cannot access a property or method of a null object reference. at Charles3_fla::MainTimeline/onenter()" pops up A LOT in the output. I don't know how to fix it, and would like help. P.S. I am using Adobe CS5 with actionscript 3
I am a beginner in actionscript coding and I am getting the error below when I click the "new game" button : TypeError: Error #1009: Cannot access a property or method of a null object reference. at aircombat1_fla::MainTimeline/moveMyfighter()
My code look like this : Code: Select allstop(); scoreDisplay.text=score.toString(); timeDisplay.text=seconds.toString(); Mouse.show(); myfighter.removeEventListener (Event.ENTER_FRAME, moveMyfighter); enemyTarget.removeEventListener (Event.ENTER_FRAME, moveEnemy); newgame_btn.addEventListener(MouseEvent.MOUSE_DOWN, startnewgame); [Code] .....
I am creating a platform game and am getting the following error:#1009: Cannot access a property or method of a null object referenceThis error happens when I remove all children from the stage on line 154 of the Robbery.as class. Im guessing that maybe it is still listening for event in the other classes but I'm unsure how to remove these from within the document class.
I'm currently making the basic groundwork to a game. On my main timeline I have two frames. The first frame has the 'start screen' let me say, which actually is a little different to the norm in that you can move your character across the screen and activate thinkg to pop up like instructions, so kind of making agame of your standard first screen if that makes sense, like the opening to the game Braid.I have it so that when the character touches (hitTestObject) a square the frame goes to (gotoAndStop) frame 2, and then on frame 2 the actual game will start.The error is this: TypeError: Error #1009: Cannot access a property or method of a null object reference.at gameBasis_fla::MainTimeline/startGame()It shows on the output panel for my three functions - one function is for keypresses, the other for an enter_frame popup animation and the other is the function which takes the game from frame 1 to frame 2!
ActionScript Code: function fadeOutF(evt:Event):void{ if (characterBoy_mc.hitTestObject(house_mc)){