ActionScript 3.0 :: Hittest Object Within An Object Array?

Mar 15, 2011

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!

View 4 Replies


Similar Posts:


ActionScript 3.0 :: HitTest On Array Object - Using RemoveEventListener?

Apr 6, 2010

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] .....

View 4 Replies

ActionScript 3.0 :: Apply Hittest Object Between Two Array?

Dec 5, 2009

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.

View 6 Replies

ActionScript 3.0 :: HitTest - Object Detection / Looping Through Array

Oct 14, 2011

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] .....

View 6 Replies

ActionScript 3.0 :: Flash Hittest Only Works On Last Object In Array

Mar 24, 2012

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.

View 4 Replies

ActionScript 3.0 :: Adding Child To An Array And Applying Hittest Object?

Mar 20, 2012

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.

View 6 Replies

ActionScript 2.0 :: Use ShapeFlag HitTest For An Object Inside An Object?

Jan 7, 2009

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)) {

View 2 Replies

ActionScript 3.0 :: Loading The Object With The Part Pushing The Object To The Array At The End - Not Working

Aug 4, 2009

I created an array in the var declarations with Code: var private eDrag:Array In a function that adds imported mcs to the stage, I also added code to push each to the array. Here is an example of a block of code loading the object with the part pushing the object to the array at the end:

[Code]....

View 4 Replies

ActionScript 2.0 :: Web Service [object Object] - Get The Array Values Back Out As A String?

Apr 4, 2011

I'm working with a web service and am returning an array to a field (that I set the data type as an Array). The result thus far is "[object Object]". How can I get the array values back out as a string?

View 0 Replies

ActionScript 3.0 :: Combining Object Array And Accessing Object Property Name

Apr 2, 2010

I have an xml say in following format

[Code].....

What I should do is parse an xml and from its node name create object property and then create an object array based on those property. Am I able to make myself clear.

View 4 Replies

ActionScript 2.0 :: Retrieving Object Properties From Object Array?

Nov 11, 2007

I'm basically loading an XML file to assign instances of a movie clip a distinct value, which it uses to modify its height. So, I'm looping through the xml and instantiating my class Object each time (Rect) and then placing that Object into an array:

Code:
function loadXML(loaded){
if(loaded){
var boxArray:Array;
xmlNode = this.firstChild;

[code]....

the trace here always comes up undefined. "listPosition" in this bit is an Rect parameter, defined in the previous bit of code as "i", so I can keep track of the order of the stack.I've found one or two examples of putting objects into an array and getting them back out, but it doesn't seem to work with this, maybe because I'm using a class. I don't know.Could this be an area where I need to use the array access brackets, like around the movie clip the object is loaded into. I've tried everything I can think of -- referencing back to the movieclip, adding extra objectRef type parameters... nothing has worked yet.

View 3 Replies

Flash :: AS3: HitTest Any Object

Apr 6, 2011

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)

View 2 Replies

Flash - Copy XML Array From One XML Object To Another Xml Object

Dec 8, 2009

how to copy one xml object values from one xml object to another empty xml object.

I have one xml object from the xml array and need to copy that to another xml object. How can i copy xml from one object to another

if am parsing the XML object with for loop and i get the nodes

var myXML:xml = new xml();
for(...)
if(xmlObj.product[i].name == 'myproduct'){

[Code]...

View 2 Replies

ActionScript 1/2 :: Hittest On Every Object On Stage?

Feb 27, 2012

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?

View 3 Replies

Actionscript 3 :: Get The Object Type From A HitTest?

Jul 10, 2010

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

Eg.

if(_groundType1.hitTestPoint(_player.x, _player.y, true))
{
if(_groundType2.hitTestPoint(_player.x, _player.y, true))

[Code].....

View 1 Replies

Flash :: Use HitTest Between BitmapData And An Object?

Aug 23, 2011

I have converted a PNG into a bitmap, then converted that into bitmapData.

I have a object called _player, and I wish to add collision detection, however I can seem to get it to work.

my code is:

if(bmd1.hitTest(new Point(_player.x, _player.y))){
trace("hit");
}

bmd1 is my bitmapData,_player is the object is wish to test against.

I am getting the following error:

1136: Incorrect number of arguments, Expected 3

I have looked around but cannott find what argument I am missing

I have tried

if(bmd1.hitTest(new Point(_player.x, _player.y), 50, _player)){
trace("hit");
}

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

View 3 Replies

ActionScript 2.0 :: Get HitTest Position Of Th Object?

May 26, 2010

My Question is how i deduct the position of the hitTest Objecti mean to say which angle he hit X Y and after hiting it must be goo that angle

here is my code
import mx.transitions.Tween;
import mx.transitions.easing.*;

[code]......

View 4 Replies

ActionScript 3.0 :: Allow HitTest Of MovieClip To Hit Only One Object?

Jul 19, 2010

Is there a way that only allow hittest of a mc to hit one objects, if it hit multiple object it ignore it?

View 1 Replies

ActionScript 3.0 :: Tweening Object Perform Hittest?

Nov 15, 2009

Can an object that is tweening via TweeLite perform a hittest on another object?? I've looked in the documentation but can't find the answer.

View 1 Replies

Professional :: 3 Object HitTest - Removing Instance

Jul 7, 2011

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] .....

View 2 Replies

ActionScript 2.0 :: HitTest Of Moving Object With Mouse?

Dec 17, 2009

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..

[Code]...

View 0 Replies

ActionScript 2.0 :: HitTest - Passing Object Name As Parameter

Jun 16, 2004

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?

View 3 Replies

ActionScript 2.0 :: Using Hittest For A More Irregular Object Than A Circle?

Dec 15, 2004

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

View 2 Replies

ActionScript 3.0 :: RemoveChild Object From Stage Can Be Detected By Hittest

Apr 4, 2010

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.

View 1 Replies

ActionScript 2.0 :: Generic HitTest - Detect Collision With One Object

Oct 13, 2005

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.

View 3 Replies

ActionScript 2.0 :: HitTest - Object Touches Side Of Rectangle?

Oct 24, 2006

Just like the picture below, I only want the codes execute if the object touches the side of the rectangle, but not the corner, how do I do that?

View 1 Replies

ActionScript 1/2 :: HitTest - Reset Game When Falling Box Touch Certain Object

Jun 30, 2009

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]

View 6 Replies

ActionScript 3.0 :: Apply Hittest Object / Point Condition To Only One MovieClip?

Jul 9, 2011

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..

View 2 Replies

ActionScript 3 :: MovieClip HitTest - Fire Event When Object Clicked By Mouse

Oct 25, 2011

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] .....

View 1 Replies

Actionscript 2.0 :: Group To Object When One Object Is Drag Across The Screen The Other Object Sticks With It

Mar 26, 2009

is there a way in action to group to object so when one object is drag across the screen the other object sticks with it, im using flash btw

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved