tag:blogger.com,1999:blog-3483659422655719681.post6832869506356438986..comments2023-09-06T03:43:00.929-07:00Comments on TrainingTutorials101.com: Simple AS3 Collision Detection Using the AS3 hitTestObject() Methodtuts101http://www.blogger.com/profile/07702671291573608054noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-3483659422655719681.post-26963618795978822652018-11-13T04:06:43.638-08:002018-11-13T04:06:43.638-08:00Doesn't work in CS5 either. Same problem. The ...Doesn't work in CS5 either. Same problem. The Instance or the Object is not active when the code runs. what to do?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-73095458546305141402017-05-09T12:12:07.177-07:002017-05-09T12:12:07.177-07:00I'm pretty new to flash but I believe if you w...I'm pretty new to flash but I believe if you want to use a new script file, create a new ac3 file (example: gameController.ac3) and put it in the same folder as your flash file then in the properties inspector of the flag file type in the 'gameController' into class descriptionAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-51217425455163373492015-03-05T01:17:19.238-08:002015-03-05T01:17:19.238-08:00I followed every tutorial before this and I'm ...I followed every tutorial before this and I'm working on this atm. But we work with actions layer every time, how can I do all of these with new actionscript files?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-21120754475863510972014-02-07T18:35:48.960-08:002014-02-07T18:35:48.960-08:00Is this specific example giving you problems in CS...Is this specific example giving you problems in CS6?tuts101https://www.blogger.com/profile/07702671291573608054noreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-12020782400971393432014-02-07T11:49:52.641-08:002014-02-07T11:49:52.641-08:00AS3/CS6 (does not work): One of the reasons I beli...AS3/CS6 (does not work): One of the reasons I believe hitTestObject does not work in Flash CS6/Flash Builder is because when one runs the 'app' for the first time objects are not 'activated'. EXAMPLE: a square drops from the top...when it collides with another square at the bottom and using hitTestObject..it should work...but it won't...why?, because the falling square is 'active' but mysteriously the bottom square is not...once we 'touch' that lower object...then it becomes 'active' : QUESTION IS: HOW DOES ONE MAKE OBJECTS 'VISIBLY ACTIVE' WHEN WE RUN OUR APP? - hitTestObject in my experience has not worked 99 percent of the time and the code will be correctly scripted.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-15088076142789087172013-08-26T23:43:31.497-07:002013-08-26T23:43:31.497-07:00Thanks a lot!!! No words.. very very good...Thanks a lot!!! No words.. very very good...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-61350837887549316642013-07-04T10:02:13.413-07:002013-07-04T10:02:13.413-07:00thanks a lot, this made possible my flash rpg. :)
...thanks a lot, this made possible my flash rpg. :)<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-45870807511853260222013-03-15T21:23:30.539-07:002013-03-15T21:23:30.539-07:00Movie clip's rectangular bounding area creatin...Movie clip's rectangular bounding area creating problem.... is there any solution for this????? <br />hitTestPoint() method is also not working because it detect the collision only when the object's pivot point hits the pivot ponit of hitObject..<br />Pls let me know if anyone has the solution for this....Rakeshhttps://www.blogger.com/profile/09499015180140547586noreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-18622892460319545832012-07-02T19:50:21.087-07:002012-07-02T19:50:21.087-07:00That's great! :)That's great! :)tuts101https://www.blogger.com/profile/07702671291573608054noreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-46543041024994529622012-07-02T09:33:06.978-07:002012-07-02T09:33:06.978-07:00Wow! I got it!!
Moving a character with arrows and...Wow! I got it!!<br />Moving a character with arrows and making it stop as it hits a wall withought bugging:<br /><br /><br />import flash.events.Event;<br /><br />stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_PressKeyToMove);<br /><br />function fl_PressKeyToMove(event:KeyboardEvent):void<br />{<br /> switch (event.keyCode)<br /> {<br /> case Keyboard.UP:<br /> {<br /> char_mc.y -= 15;<br /> if (char_mc.hitTestObject(shelf_mc))<br /> {<br /> char_mc.y +=15 ;<br /> }<br /> break;<br /> }<br /> case Keyboard.DOWN:<br /> {<br /> char_mc.y += 15;<br /> if (char_mc.hitTestObject(shelf_mc))<br /> {<br /> char_mc.y -=15 ;<br /> }<br /> break;<br /> }<br /> case Keyboard.LEFT:<br /> {<br /> char_mc.x -= 15;<br /> if (char_mc.hitTestObject(shelf_mc))<br /> {<br /> char_mc.x +=15 ;<br /> }<br /> break;<br /> }<br /> case Keyboard.RIGHT:<br /> {<br /> char_mc.x += 15;<br /> if (char_mc.hitTestObject(shelf_mc))<br /> {<br /> char_mc.x -=15 ;<br /> }<br /> break;<br /> }<br /> }<br />}Diogo Candeiasnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-53534084182577889842012-07-02T04:34:43.235-07:002012-07-02T04:34:43.235-07:00This helped me a bunch! :)
What about when you ha...This helped me a bunch! :)<br /><br />What about when you have a "character" moving with arrows, and you have some sort of bomberman like map? How do I make it verify if collision is detected anytime he hits a wall? I tried giving every piece of the wall the same instance name so that whenever the character collided with that instance, the character would stop. But unfortunatelly it only detects collision on the last created object :(<br />Help? lolDiogo Candeiasnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-5816205687325475102012-03-16T00:47:39.750-07:002012-03-16T00:47:39.750-07:00Hi, Anon.
That's because the hitTestObject() ...Hi, Anon.<br /><br />That's because the hitTestObject() method looks at the movie clip's rectangular bounding area, instead of the actual shape. I've been meaning to figure out how to create collision detection for irregularly shaped objects, but haven't had the time. But you can try doing some research on the hitTestPoint() method. This one has a parameter that lets you say if you want to test with the actual shape inside the movie clip. However, this method tests only a single point against a movie clip. Whereas the hitTestObject() method tests one whole movie clip against another, but again, it does not have the shape flag parameter. It would have been great if they could have combined these two methods. :)tuts101https://www.blogger.com/profile/07702671291573608054noreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-35306415734778797072012-03-15T16:24:40.102-07:002012-03-15T16:24:40.102-07:00Very useful tutorial! should be great for game dev...Very useful tutorial! should be great for game developing. <br /><br />But when I make the objects very freeform (squiggles), sometimes it outputs "Collision Detected" even when they are not QUITE overlapping, just close.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-20386563497372477392012-03-05T09:47:14.232-08:002012-03-05T09:47:14.232-08:00thxs this helped me with my h/mthxs this helped me with my h/mAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-62811590643815992942012-02-02T21:40:40.071-08:002012-02-02T21:40:40.071-08:00Once you know the two objects have hit you can giv...Once you know the two objects have hit you can give one of the objects new coordinates based on the overlap.<br /><br /> if (square1_mc.hitTestObject(square2_mc))<br /> {<br /> square1_mc.x = square2_mc.x + square2_mc.width;<br /> }<br /><br />that code will move square1 to the right of square2, you can then write an if statement that checks to see if the object should snap to the right or the left of the object it's overlapping, but that's the basic way of doing what you are asking.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-29055136678421384842011-12-16T01:02:36.933-08:002011-12-16T01:02:36.933-08:00very good one,but can u tell me how to avoid objec...very good one,but can u tell me how to avoid object from overlapping on other object when collision occurs?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3483659422655719681.post-62242368094761426522011-12-13T22:05:15.088-08:002011-12-13T22:05:15.088-08:00it helps me a lot.....thanks for such great tutori...it helps me a lot.....thanks for such great tutorialAnonymousnoreply@blogger.com