ActionScript 2.0 :: Hittest Doesn't Work Off The Stage?
Sep 13, 2009
I have about 100 movieclips that scroll across the stage from out of bounds. They are supposed to hit another movieclip both in bounds and out of bounds, but it seems like Flash only detects the hittest when it happens within the frame.
I have this code so that when a spaceship goes through a blackhole it plays the spaceships moveiclip. This works fine on the first part of the code when the user just clicks the start button.However, i have put in a difficulty setting and when you change the difficulty setting the hittest doesn't work anymoreand there are no error messages. I have tried putting the blackHoles array in the difficulty function but nothing changes and i didn't really think this would make a difference as the easy function is already using the blackHoles array outside the difficulty function.
So I'm doing this project for school and all, and I'm trying to do a htitest on an object. For some reason, it doesn't work. So I tried writing out my own method... Which halff worked, but wasn't as exact as it should've been.
Heres my code (Though I'm pretty sure somethings wrong with my MC, so i'll upload the main .fla file)
I am trying to capture mouse events in flash while the mouse is being held down. The intention is to keep reciving events as long as the mouse is pressed, even if the cursor leaves the flash element. That's the behavior I get on all browsers other than IE, which only fires events while the cursor is inside the stage.
I'm pretty sure I've seen such "well behaved" flash applets work in IE before.
I have a little snippet of code that allows the user to create a line with the mouse, and clears the line if they end up touching the hitbox with the mouse, while they're drawing the line. It works fine when it's just thrown onto the main timeline. However, when I try to encapsulate it within a movie clip, it suddenly doesn't work. At all. Are there any suggestions as to why this is happening? Here's the code.
I added a movieclip and named "bot_mc" in another movieclip. Then, In Action panel, I use bot_mc.addEventListener(MouseEvent.DOWN, xxxx). However, when I drag and drop the container movieclip on the main stage and compile. There is no error occurs but the MouseEvent doesn't work.
I decided to try to use setInterval for myanimation, which is just a mouse trail.However, I'm trying to get teh mouse trail to be a dynamic mask.In my previous swf this was achieved by using a holder mc with the animation inside and then using this as the mask. But this time I just canpt seem to hit on the right way to get it to work. The code I am using for the mouse trail is:
Code: var i:Number = 0; var myInt:Number; var t:MovieClip;[code].....
in the function, but now the trail doesn't resize and the mask still doesn't work.
I am trying to create a game. My game is birds eye view game and I am trying to get it so my character (instance name hero_mc )can't pass through the buildings(instance name block_mc). I have been looking at tutorials on the web and most of them cover it so that a text appears if you hit the object whereas I want it so my character can't pass through or well is "push back", the one tutorial I found doesn't want to work for me, but it's not giving me any errors so I really don't know what is wrong with it.
Actionscript Code: hero_mc.addEventListener(Event.ENTER_FRAME, enter_frame); function enter_frame(event:Event):void{if (hero_mc.hitTestObject(block_mc)) { trace("hero _mc is next to block_mc") } else { hero_mc.y += 10 hero_mc.x += 10 } }
My character still passes through the block objects.
I have this very simple .fla file and you use the keys to move the bus around. As it detects the hittests with the other movie clips on the stage it goes to and plays a frame on that mc's movieclip. It all works fine but i dont want the hittest to repeat after it has done it once(on each movie clip) so that as you drive the bus around you reveal the photo. [URL]
Code: //The Austin Weisgrau (El Nacho) //Blob Game, to go with the video so it will get like the .3 mor it needs not to be blammed
[Code]....
the character instance is Blob and the background instance is Background. i can't get the hitTest to work with either of those two things in the /* */ and i need to no how i can
For some reason I cannot get my hitTest to work on an mc within an mc within an mc...which is assigned to a variable...
Code: var miniWin:MovieClip = CAD_mc_mini.zoomControl.miniWin; trace(miniWin); //returns _level0.CAD_mc_mini.zoomControl.miniWin var mouseListener: Object = new Object();
I was trying to make it so you had to hold up this ball, and if it touched the block near the bottom of the screen, it would go to the first keyframe. (The menu.) So, I labeled the ball, "ball", and the block, "block". Then, I added this code to the block:
onClipEvent (enterFrame) { if (ball.hitTest(block)){ gotoAndPlay(1)[code]....
And tested it out. To my dismay, it didn't work at all. I've spent about 30 minutes testing other ways, and I cant seem to make it work.
import flash.display.BitmapData; import flash.geom.Point; // var BitmapA:BitmapData = new BitmapData(550, 400, true, 0x00);
[code]....
This is using the bitmapdata.hittest way to check whether the one bitmap is overlapping the other. Throug pixel-to-pixel detection.But I'm having trouble understanding this line:
Code:
if (BitmapA.hitTest(destPoint, 255, BitmapB, currPoint, 255))
I know that destPoint is the topleft point from which it is determining all opaque pixels. No value is given to destPoint so basically it is checking from 0,0. Having determined all opaque pixels from that bitmap it should compare them with the opaque pixels of the other bitmap. But why does currPoint use the topleft coordinate of its movieclip? Couldn't it just as well use 0,0 too? I mean when determining the opaque pixels of bitmap two it might as well start checking for those from 0,0 as the topleft position as well?
i am making a game where a ninja runs through a course, every thing is running smoothly. EXCEPT hittest will not work, hittest never works on ANY of my projects. I know im doing it right, because ive even tried copying and pasting working ones. Look at the attached fla file to see what im talking about.is it my computer that wont let it work, because the exact codes worked for all of the people on youtube that used it.
I am trying to use the following code to simplify multiple Hittests using an Array, but the code won't work. Can anyone tell me why?
var blockArray:Array = new Array("block1", "block2", "block3"); player.addEventListener(Event.ENTER_FRAME, blockTest); function blockTest(evt:Event):void {
I'm having a problem with my dragOver function.The point of my project is that can drag the items that are on the table to the little bag (this is a button) on the left bottom of the screen.The thing is that the dragging works but when I perform a hitTest the item is supposed to dissapear, but it doesn't....
I have a button object that I need to scale to align with the variable width of an array of images.However, when I set the width in code, the button does not actually become that width. Tracing out the width gives me the correct value, but on screen.. it's off.
I've proved it to myself by scaling the same button object manually in the properties pane and visually comparing. Both of the buttons below have a width of 410.
I am having trouble getting a hitTest to work. My two MCs are lines, one horizontal, one slanted. When the horizontal line gets within the "bounding box" of the slanted line the hitTest is true, but it's not touching the slanted line yet. I saw that the shapeFlag property comes into play here, but only when using coordinates... I'm not sure how to apply it to these two lines. I want the hitTest to be true only when the lines actually touch. I have attached a simple FLA of the problem.
Lets say that I got movieclips A,B,C,D in my scene and E,F which only come into scene when A hitTest B and C hitTest D.I was able to make the A+B and C+D hitTest functioning properly. But when E,F came into the scene, I tried to make E to hitTest F to get something else function but they won't work.# note that there is some short animation before E & F come into scene.I am pretty sure all the instance names are named properly.
Is there an easy way I can hitTest using mousex and mousey on the stage, disregarding any objects on the stage (so it does not register if the user fires an onMouseDown event if it's over a movieclip for example).I tried using a plain _root.hitTest and this.hitTest (in actionscript for the game frame), but it still registers all over the stage including over movieclips etc.
for some reason the hitTest I have setup in the attached file seems to work in relation with the blue box's that surround objects and not with the actually objects. Anyways I'm pretty sure that it has to do with the border.
I would like to know if there's the way to do collision check on every object on the stage,
[Code]...
I want to make the object such that it falls on a rotated platform and land according to it's angle. I've success fully make it landed according to it's angle before it lands. but the problem here is that, after the landing when I trigger the rotating platform, the object falls when the platform is out of it's hit area. Is there a way such that it will work like a car wiper and wipe the object towards it's direction?
I'm getting really tired of AS3 now because I cant get it to do basic things like hit tests which were so easy in AS2. Basically, I generate a number of fish of varying scale, speeds and directions using this on the first frame of the timeline and the constructor function in the fish.as file:
ActionScript Code: function DisplayFish() { for (var i:int = 0; i < 20; i++) { var newFish:fish = new fish(); this.addChild(newFish); [Code] .....
What I want to do is rather than setting a max / min x/y use a hit test with a side wall MC on the stage, and a hit test between this instance of fish and all other fishes so they bounce off each other. I've tried so many ways of hit testing from within the class with MCs on stage but just cant get it to work. ActionScript Code: if(this.hitTestObject(root.LeftWall)){ directionX = 1; }
If I removeChild an object from the stage can it still be detected by a hittest? I have objects that are tweening off the stage and if they hit other objects they stop their tween i use removeChild to remove objects that I don't want a hittest to occur on which is the nature of my question.
as the title says i am having two movie clips on main stage one called "land" and other called "char" inside "char" MC i have another MC called "ht1" i want to make hitTest between "ht1" and "land" but everything seems to fail, i've tried using _root, _parent?
i have a hit test point on display object, and if i exit stage over that display object, and then run hit test point it will return true, although my mouse is not over stage area any more, like it remembers the last mousex, mousey coordinates where mouse was and reports that.how do i deal with it?i know i can detect mouse_leave on stage and mouse_out on displayobject.
Is there any way to hitTest a MC that is on the main stage with another MC from the library? i want to have multiple instances of the same object but dont want to go around labeling every instance with the same name, and applying the hitTest function to every instance of this MC wouldb't be wise. I have a MC inside an other MC that i am trying to hitTest with a single moveable MC on the main stage. The code i am currently using is: