As3 Error #2007 Parameter Hittestobject Must Be Non-null
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up AS3 Flash - Error #2007: Parameter hitTestObject must be non-null up vote 0 down vote favorite I'm using Flash to create a platform game and i'm just trying to add an if statement with hitTestObject in to trace some words but when i hit platforms but I keep getting the error "Parameter hitTestObject must be non-null". Here's my code: //variables public var jon: Player; public var platforms:Platform; public function gameloop(Event) { //applying gravity jon.y += gravity; //adding movement if (moveLeft == true) { jon.x -= xspeed; jon.scaleX = -1; } if (moveUp == true && isJumping == false) { isJumping = true; jon.y -= yspeed; } if (moveRight == true) { jon.x += xspeed; jon.scaleX = +1; } //adding collisions for platforms **NOT WORKING** if(jon.hitTestObject(platforms)) { trace("hello i am working"); } } actionscript-3 flash collision-detection share|improve this question asked Feb 17 '15 at 23:05 Callum Singh 446 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted The error indicates that platforms is null. Neither jon or platforms is created in the code you posted, I'm guessing these are timeline symbols? Make sure you have given a symbol the name platforms in your timeline, and make sure it exists on the frame that gameloop is added. share|improve this answer answered Feb 18 '15 at 1:51 Aaron 5,2821524 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy p
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the http://stackoverflow.com/questions/28572910/as3-flash-error-2007-parameter-hittestobject-must-be-non-null Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error #2007: Parameter hitTestObject must be non-null up vote 0 down vote favorite this is my code- it's working and moving to frame http://stackoverflow.com/questions/14810065/error-2007-parameter-hittestobject-must-be-non-null 3 but everything is stuck there and I get this Error #2007 function createMC(event:Event):void { var hasa_mc:MovieClip= new hasa(); stage.addChild(hasa_mc); var halfMc:int=hasa_mc.width/2; hasa_mc.x=randomNum(70+halfMc,480-halfMc); hasa_mc.addEventListener(Event.ENTER_FRAME, abc); hasa_mc.addEventListener(Event.ENTER_FRAME, dropCheckHit); function dropCheckHit(event:Event):void { if (hasa_mc.hitTestObject(hauta1_mc)) { hasa_mc.removeEventListener(Event.ENTER_FRAME, dropCheckHit); event.target.parent.removeChild(event.target); countertime++; score_txt.text=String(countertime*10) if (countertime==10) { gotoAndStop(3); } actionscript-3 flash share|improve this question edited Feb 11 '13 at 10:23 NAZIK 4,446114291 asked Feb 11 '13 at 10:17 user2051003 32 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted The error code and description refers to the line: if (hasa_mc.hitTestObject(hauta1_mc)) { My guess would be the movieclip hauta1_mc does not exist on frame 3 of your movie, so once you go to frame 3 and your dropCheckHit function executes the null reference error is thrown. To resolve you can remove the enter frame listener and stop checking if the movieclip has been hit: if (countertime==10) { hasa_mc.removeEventListener(Event
Start here for a quick overview of the site http://gamedev.stackexchange.com/questions/51467/type-error-for-hit-testing-two-objects-created-with-actionscript Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more http://board.flashkit.com/board/showthread.php?827680-TypeError-Error-2007-Parameter-hitTestObject-must-be-non-null about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Game Development Questions Tags Users Badges Unanswered as3 error Ask Question _ Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and as3 error #2007 rise to the top Type Error for hit testing two objects created with actionscript up vote 0 down vote favorite I am making a zombie shooter game where I get an error when I try to hit test two objects created with actionscript. Could someone post a possible fix please. Here is the Error Code; TypeError: Error #2007: Parameter hitTestObject must be non-null. at flash.display::DisplayObject/_hitTest() at flash.display::DisplayObject/hitTestObject() at game3_fla::MainTimeline/zombiemove() and here is my game code; import flash.events.Event; var zombiehits:Number = 2; var numzombies1:Number = GenerateRandomNumber(10); var zombie : Z = new Z(); var objz; var objb; stop(); //Change mouse crosshair_mc.mouseEnabled = false; crosshair_mc.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor); Mouse.hide(); //EventListners; stage.addEventListener(Event.ENTER_FRAME, alwayson); stage.addEventListener(MouseEvent.MOUSE_MOVE,facecursor); stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown); //Code; var startcountdown:Number = 5; var fl_CountDownTimerInstance:Timer = new Timer(1000,startcountdown); fl_CountDownTimerInstance.addEventListener(TimerEvent.TIMER_COMPLETE, startgame); fl_CountDownTimerInstance.start(); function createZombie():void { zombie.rotation = 90; zombie.height = 85.35; zombie.width = 55.9; zombie.x
TypeError: Error #2007: Parameter hitTestObject must be non-null. If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 1 of 1 Thread: TypeError: Error #2007: Parameter hitTestObject must be non-null. Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 07-16-2012,02:36 PM #1 Kitsunne View Profile View Forum Posts Junior Member Join Date Jul 2012 Posts 2 TypeError: Error #2007: Parameter hitTestObject must be non-null. Hey guys I've been trying to figure this out for some time now, I have this flash game I'm trying to make, nothing special, apples are falling from trees and I made a object to catch them, etc, etc. When I made the game it ran fine, up until the point where I added Scnes to my flash. I made a title scene and game scene, and was going to make a game over, win/lose screen. But the button on my TitleScene as soon as it's clicked it gives me this error: TypeError: Error #2007: Parameter hitTestObject must be non-null. I'm sure it has to do with the code on the GameScene but I couldn't pinpoint it. Any help would be appreciated Below is my code for the Title Page: stop(); start_btn.addEventListener(MouseEvent.CLICK, startGame); function startGame(event:MouseEvent):void { gotoAndPlay("GameStart", "Game"); } And Below is the code for the GameScene I'm trying to access: var fruitArray:Array = new Array(Apple1,Apple2,Apple3,Apple4,Apple5,Apple6); var fruitsOnstage:Array = new Array(); var fruitsCollected:int = 0; var fruitsLost:int = 0; for (var i:int = 0; i<20; i++) { var pickFruit = fruitArray[int(Math.random() * fruitArray.length)]; var fruit:MovieClip = new pickFruit(); addChild(fruit); fruit.x = Math.random() * stage.stageWidth-fruit.width; fruit.speed = Math.random() * 15 + 5; fruitsOnstage.push(fruit); } basket_mc.addEventListener(MouseEvent.MOUSE_DOWN