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


Similar Posts:


ActionScript 2.0 :: Objects - XML - Creating A New Instance Of An Object That Uses An Identical Name To An Older Instance Delete The Previous Instance?

Mar 20, 2009

Does creating a new instance of an Object that uses an identical name to an older instance, delete the previous instance? Or should the original instance be deleted first? The code uses a ridiculous amount of XML vars. Isn't it less memory intensive to parse the XML and save the properties to an Object, and then delete the XML Object, rather than keep the XML Object around and reference it's child nodes directly? Is it better form to break up a huge XML file (>600lines/3200vars) into smaller chunks?

View 1 Replies

Professional :: Give An Instance Name To AddChilded Object

Jan 16, 2011

i'm going in trouble with instance names, classes, methods, and addChilded object...

that's my code:

- i have a class that (everytime the function is called by the timer) add an object(class "Monster") to the stage.

[Code]....

I also tried to avoid the problem changing my point of view; so i inserted the hitTestObject test into the loop for each ( var enemy:Monster in army ) but the same problem occurred, i have a lot of balls that doesn't have an instance name (or they have all the same one).

This is what i created until now [URL]

View 2 Replies

ActionScript 3.0 :: Different Movieclips Same Instance Name - HitTest

Jan 3, 2011

I'm creating a platform game, and I have those boxes which needs hitTests on all sides - including the bottom.I want my hit areas to have the same instance names. With that I mean, that I want only one instance name for all the bottom hits, one instance name for alle right hits - and so on. If it's possible. 'Cause else there will be so much actionScript code to write.I've been trying to simply make a normal hitTest on for example hitGround, and then place two movieclips with the instance name hitGround, but the hitTest function only works on the last added movieclip with that instance name.I have also been trying to look up some for each in-arrays, but I don't really get the meaning of how to use them.

View 2 Replies

ActionScript 3.0 :: Accessing An Instance Of Parent Movieclip For HitTest?

Dec 13, 2009

I have a stage with instances of bauble_mcs on it that are attached by the document class of the main timeline (can someone tell me what the right term is here? I don't know what I call the main time line in AS3).I then have instances of snow_mc attached by the same class. Inside the snow_mc I want to test to see if it is hitting any bauble_mcs but I don't know how!

inside snow_mc I am trying:

PHP Code:

if(this.hitTestObject(this.parent.bauble_mc)){
}

to which flash says:

1119: Access of possibly undefined property bauble_mc through a reference with static type flash.displayisplayObjectContainer.

View 1 Replies

ActionScript 2.0 :: HitTest Detect Random Duplicated Instance?

Sep 25, 2005

I've got this code on my frame:

if (_root.count <= 20) {
duplicateMovieClip("_root.clip", "clip"+_root.count, _root.count);
_root["clip"+_root.count]._x = random(500)+50;
_root["clip"+_root.count]._y = random(1)+20;
}

And I need to figure out how to have the hitTest see the randomly generated instances of this duplicated mc.

I can get the hitTest to see the first instance (called "clip"), but then it doesn't see all the rest.

Here's the code I have on the hitTestMC:

onClipEvent (enterFrame) {
if (_root.chime1, hitTest(_root.clip)) {
_root.chime1.gotoAndPlay("play1");
}
}

View 1 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 :: 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

ActionScript 2.0 :: Use Local Instance Variables Vs Attach New Properties To The Instance Object?

Mar 14, 2006

I am wrapping my brain around OOP in AS2. I am making two posts on two different subjects. My question here is: when should I use local instance variables, and when should I attach new properties to the instance object? (Feel free to correct my terminology.) Let's say I have a class for a scrolling background, which scrolls when I mouse over its edge. I want to put these values somewhere:

1) How wide is the border in which a mouseOver makes it scroll? This is basically a semi-constant I set it up once and keep it the same, unless the user changes it in an options menu to make the border wider or narrower. Call this scrollBorderWidth.

2) How fast is the background scrolling now? I want to track this so I can smoothly change the scroll speed over several frames. This is often changed. Call this scrollSpeed.

It seems I have two ways I can store and access these values and darned if I know which is better practice. METHOD A: Make them local variables in the class, so the scrolling background instance has them as local vars. I set them up thusly:

[Code]....

View 4 Replies

ActionScript 3.0 :: Breaking Symbol Without Removing The Instance Name?

Dec 16, 2010

I selected all my stuffs & make them into a symbol and when i break the symbol up all the instance name was removed. Is there a way to break up the symbol without removing the instance name?

View 2 Replies

ActionScript 3.0 :: If Statement For Removing Video Instance?

May 3, 2011

is there a way to remove a video instance from the stage with an 'if statement"?
Kind of like :next1_btn.addEventListener(MouseEvent.CLICK, ongoPage2);
function ongoPage2(Event:MouseEvent):void {

[code]......

View 3 Replies

ActionScript 3.0 :: Removing Eventlistener From Deleted Instance?

Jan 18, 2010

in my main I have a system that allowed certain classes to be loaded and unloaded. When I load Game.as, it contains a trace statement when you press the left arrow key. When I remove the game instance from the stage, and set it to null, I can still press left arrow key, and the trace will come up. If I then make a new instance of game, it traces twice with only 1 click. When I close/load another time it traces three times.

I very specifically set:

Code:
mainContent.removeChild(game);
game = null;

Even trace statements confirmed that the game was being nullified, and the trace still continued.

View 10 Replies

ActionScript 3.0 :: Removing Enemy From An Array, Instance Still Is On Stage?

May 8, 2010

Alright, so really I am having 2 difficulties here.

1) When a bullet hits an enemy, if 2 zombies are beside eachother, the bullet hits them both -- How can I make it so the bullet can only hit one?

2) When an enemy has health of 0, it dies, I am trying to get the enemy to be removed from the array that the bullet searches through so it will no longer be affected by the enemy, but it doesnt seem to work, the bullet still hits where the enemy was, as if the enemy is invisible.

[Code]...

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

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

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







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