i got 4 movie's on main (category0_mc, category1_mc, category2_mc and category3_mc) the _y position of these 4 movie's is variable.....
i want it so that when i start drag "categorie0_mc" you only can drag to (category1_mc, category2_mc and category3_mc) and when release "categorie0_mc" change _y position with the other categorie movie
i got 4 movie's on main (category0_mc, category1_mc, category2_mc and category3_mc) the _y position of these 4 movie's is variable.....i want it so that when i start drag "categorie0_mc" you only can drag to (category1_mc, category2_mc and category3_mc) and when release "categorie0_mc" change _y position with the other categorie movie.
Ive got a code to move a MC on the main stage together with the mouse, in the the X axis,. difficult to explain. But now the client wants that this MC movement works only when the Y position of the mouse is over the 300 px. I thought I need a hit test or something elese. Please help. Here is the whole code.
This seems like it should be simple, but... I've been trying to figure out how to do the following, and I can't seem to make it work. It all works except for the hit test part. I have a working drag and drop application. I need something different to happen when the user drops an object while the mouse x,y is, or is not over a certain (very irregularly shaped) bitmap inside a movieClip. how to do this? I have found some complicated ways to hit test between 2 bitmaps, but not 1 bitmap and mouse x,y.
ok so if i have an obect called square1 and an object called square2 and inside square2 i have hitArea... i want to use shapeflag to detect an absolute true hitTest on just the area of square1 not the bounding box.... i tried this code and it didnt work...
actionscript 2.0
ActionScript Code: if (_root.square1.hitTest(square2.hitArea._x, square2.hitArea._y, true)) {
I have a function that checks if 2 objects are touching OB1 and OB2, if they do touch it runs the rest of the collision code where OB1 is the character and OB2 is a tile that the player cannot pass through.
I came across an issue where i wanted sprites to be separate from the hitboxes but my collision code works by checking the height and width of an object (you guys know the drill).
So i have a Tile class with 2 parts to it, a bitmap and a movieClip.
So i have this setup(pseudocode):
Code: loop { function collision (ob1 , ob2[loop].movieclip) }
This should work right? But it ONLY works for the first object in the loop!
I am working on an application where an image serves as cursor. Now i would like to know at any time over which object the cursor is hovering. Sort of like a HitTestObject(*) where i can then see what object the * represents. how i could accomplish this? (and using the mouse is not an option)
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 coding a really simple 2D platforming game in Flash using AS3. I'd like to define two different types of terrain surfaces that the player can walk on based on classic platforming elements. Type1: the player can walk on, and if the player jumps, they will hit their head on it and bounce back to the ground. Type2: the player can also walk on, but if the player jumps and hits their head, they will simply pass through the surface and not bounce back to the ground.
I am using hitTestPoint to resolve collisions for this. My question is: What would be the best method to test for what TYPE of ground I am colliding with? Each ground type has it's own Class associated with it in my Flash IDE and all the different terrain surface types are in the same movie clip on the stage.
Currently I'm testing to see if it hit one type of ground surface, then i'm testing if it hit the other, and then based on those results, I process what I want to happen. This seems to work okay right now, but I'm imagining that I may want to create more than 2 types of ground to collide with. For example, moving platforms. It seems like the code will start to get complex
I should mention that the reason for me taking this approach is that I have a PNG, with transparent areas, I need to test for collisions in the non-transparent areas, which is why I was using this approach
I have a PNG, i import that and convert to bitmap, then convert to bitmapData
I was using hitTest to see when sunny (mc) would hit one of five objects I have in an array. But I had to use removeEventListener otherwise it would keep occurring. But now I can't "hit" the next object. Why doesn't the addeventListener work again?
stage.addEventListener(MouseEvent.CLICK, myClickReaction); // speeds ALONG NYPOTENUSEvar v:Number=5; var varObject:String; var i:Number; var arrayObjects:Array; [Code] .....
I am trying to make the instance 'red' be removed when all 3 objects have hit it here is my code:
var hit = 0; addEventListener(Event.ENTER_FRAME, hittest); function hittest(e:Event){ addChild(blue);addChild(green); addChild(pink); addChild(red); [Code] .....
adding multiple childs to an array these childs are added using timer after a time interval.actually there two classes and child of both classes are added to stage one through timer as i described and other through keyboard event. now is it possible to do this if yes than how?? and is it possible to apply hittest object between these two array.
My first post in Actionscript.org. but I'm a long time visitor / fan. I'm moving a object with mouse but using some easing values. means it will follow the mouse slower.
Here is the file.[URL].. How can i check hitTest in this situation. even if i do it normally...the object is passing the collision object simply before stopping..because its being moved with mouse..
I'm having troubles activating the HitTest, passing the objects name as a parameter through a global function. Let's say there is the following function on the main timeline:
Code: _global.fallIntoBasket = function (fallingObject) { if (_root[fallingObject].hitTest(_x, _root.basket_mc._y+(_root.basket_mc._height/2)-7, true)) { trace ("teste"); _root[fallingObject]._alpha=0; }}
I then call this function passing the this._name of the object as a parameter in a onClipEvent (EnterFrame) on each of the falling Objects action box. The whole detection thing doesn't work though... but if I place the hitTest code on each of the object, and change the _root[fallingObject] to this it works. Can I not pass hitTest through a function?
ive recently made a game in which you have to avoid some big evil round planets. i found out the in the making of that that using the function hittest uses square objects. i dident bother much then with it, i just brought out the ol'e algebra book and looked up the distance formual and made my own hittest. now my questyion is is there a more refined way of using hittest for a more irregular object than a circle.
I made somewhat irregualr objects have hittest boxxes so that it was split up into many smaller parts, this gets kinda tedious if its really irregualr or if i need to move it around on the screen btw if anyone wants ta c the game i made [URL] avoid everyting , and shop at the store on the planet , u can go over the big planet in lower left corner but not the ones in orbit a few bugs still like only way to restart is the reload button in browser
I'm trying to trace the path of an object by using setPixel on the object's position every frame in a BitmapData/Bitmap pairing. These pixels aren't showing up normally and I suspect I have a fundamental misunderstanding of the BitmapData class. Here's what I'm doing:
public var contrailBase:BitmapData; public var contrail:Bitmap; private var contrailColor:uint;[code].....
Using this code, the red pixels don't show up. If I initialize contrailBase to 0xFF000000 instead then I get a black screen on which the red pixels DO draw, but I need the bitmap to be transparent except for the contrail. What am I doing wrong?
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.
I've attached a zip with a few custom classes and a .FLA. Ignore the custom classes. I'm getting repeated "Error #1009: Cannot access a property or method of a null object reference. at Environment_fla::MainTimeline/hitTest()".
I understand that this error means I'm asking it to reference something that's no longer there. How better to hitTest many objects in an array. My game involves creating a bunch of balls that will fall into buckets. I need to keep track of how many touched the buckets, how many fell off the screen, and remove each accordingly.
Here is the code from my main FLA ActionScript Code: var ballTimer:Timer = new Timer(200); var changeTimer:Timer = new Timer(50000); ballTimer.addEventListener(TimerEvent.TIMER, throwBall, false, 0, true); ballTimer.start(); changeTimer.addEventListener(TimerEvent.TIMER, changeColor); changeTimer.start(); [Code] .....
Right now I'm working on an advanced hitTesting engine, and What I'm trying to do here is create an engine that will detect collision with one object instead of two. That basically means that if any other objects touch this movie clip, the hitTest will return True. Right now the .fla containing the engine has nothing but a circle that can be moved using arrow keys and 8 squares that disappear when touched by the circle. Obviously, I could do something like:
if (circle.hitTest(square1)) { do so and so } else if (circle.hitTest(square2)) { do this and that } etc...
But that would be too long, since the engine has to be able to contain 100 squares without too much change in the code.
For days now I have been trying to get this hit test to work and which ever way I try it, it always comes back to the same result. I get a hit on the last item I pushed into my array but none on the previous items I pushed in. Also if I put a .sort() on the array it only gives a hit on the last item of the array, no matter which one I push in.
The idea is that I want to drag and drop objects onto the stage, they may not overlap so I need a hit test on the objects so I can make them undroppable when the hit test is true.
This is the part I have for dragging the objects to the stage, and adding them to arrays for the hit test.
Code: private function onClickDragBuilding1ToGameField(e:MouseEvent):void{ building1Placeholder.x = mouseX-25; building1Placeholder.y = mouseY-25;
[Code]...
Now if I run this I can add the object to the stage just fine no errors or other issues but the hit test only works on the last object I added to the stage/array and not the previous object I added to the stage/array.
Sso I drag the first object to the stage. (no other object are available yet so nothing happens, this is as it should be) Then I drag a second object to the stage, this reacts to the first object and returns the hit test as true. (Also great and working as it should.) Then I drag a 3th object to the stage, this reacts to the 2nd object I dragged just fine and return a true value, but it does not react to the 1 object I dragged onto the stage. Then when I drag a 4th object to the stage it will react to the 3th object I added, but not the 1st ad 2nd object.
I am new to flash and im trying to make a game. Im stuck on hitTest. I have many black boxes falling down and I want the game to reset when the black boxes touch my red circle. I used this code for my boxes:
[AS] this.createEmptyMovieClip("canvas_mc",10); myInterval = setInterval(addbox1,500); function addbox1() { [Code] ..... My red circle is controlled by the mouse. The code for that is: [AS]onClipEvent (load) { startDrag(this, true); }[/AS]
i'm breaking my head over something, and will be very grateful to any creative ideas:
I created kind of drag and drop game: i have cards that should be placed on squares.
in case the card touches any square, the square changes it's color. the problem occurs when the card touches 2 squares at their middle: they both change their color.
in fact, I need that only one of the square will change it's color, and it should be the square that the card touches it with "the most of him". i thought of using the hitpoint but i know it won't work, because in case the card touches both square in the middle it won't work..
regarding adding multiple childs to an array these childs are added using timer after a time interval.actually there two classes and child of both classes are added to stage one through timer as i described and other through keyboard event. now is it possible to do this if yes than how?? and is it possible to apply hittest object between these two array.
I have a MovieClip. It represents animation of jumping monster. For clearness, let's pretend there are only 2 frames: the first one occupies top left rectangle (x = 0, y = 0, w = 70, h = 70) and the second one occupies (x = 100, y = 0, w = 70, h = 70). So monster jumps from left to the right. And position of MovieClip itself is constantly = (0, 0). I'd like to fire some event when monster is clicked by mouse.
For some reason, I have stage mouse listener, not monster mouse listener. I wrote this code: stage.addEventListener(MouseEvent.CLICK, onClick); private final function onClick(e:MouseEvent):void { const clickPos:Point = new Point(e.stageX, e.stageY); // having monster:MovieClip, how do I check hitting it? [Code] .....
I'm stuck thinking about the best way to go about setting a line segment's position, I have a class Line(length, angle, previous) being called from a class Polygon. Right now I have:
public class Line extends Sprite { public function Line(length:Number, angle:Number, previous:Line = null) { if (previous != null) { this.x = previous.end.x;