ActionScript 3.0 :: HitTesting Against Multiple Movieclips Within An Array

Feb 4, 2012

im having a really frustrating problem. I have 6 movieclips on the stage, all acting as 'map areas', these are named area1_mc, area2_mc and so on.. I then have a car which i drive around the screen, this instance name is car_mc ... All i want to do is do a HitTest to determine if the car is on one of the 6 areas.. i have the following

[Code]...

The reason it is not working i think is it is expecting the car to be on ALL map areas in order for it to be "on map". For example if the car is in the middle of area1_mc, i get three traces. On map (refferign to it being on area1_mc) then two traces of 'off map', because it obviously isnt on area2_mc or area3_mc.

View 14 Replies


Similar Posts:


ActionScript 3.0 :: HitTesting Multiple Array Elements?

Nov 19, 2011

I have a tile-based platformer game under work, and I'm stuck on a problem with hitTesting:
 
//check all character collisions with levelHolder
for(var i:int = 0; i < levelHolder.numChildren; i++)
{

[Code].....

The problem here is that hitBlock only hitTests one block at a time, and when I test this: If you lean on a wall (press right arrow key) and go downwards you can go through the floor.
 
I need to make it so that I can test on multiple blocks at a time.
 
And I did try to replace hitBlock with levelHolder[i], but it gave an error saying:
 
ReferenceError: Error #1069: Property 0 not found on flash.display.Sprite and there is no default value. at Main/enterFrame()
 
I'm guessing that comes from the level array where 0 = blank block / empty space.

View 7 Replies

ActionScript 3.0 :: HitTesting An Array?

Nov 18, 2009

I have a movieclip named Map linked to a class named Map. Inside of the movieclip I have 3 instances of a movieClip hitbox. they are named block0, block1, block2. What I'm trying to do is add them to an array using a for loop. Then in my player class I use another for loop to hitTest against the array. What I'm getting tho is this error:

Code:
TypeError: Error #1034: Type Coercion failed: cannot convert []@2393159 to flash.display.DisplayObject.
at xxx::Player/loop()[Player.as:54] The code from Player.as that the error refers to is here:

[Code]...

View 3 Replies

ActionScript 2.0 :: Duplicate Multiple Movie Clip And Then Hittesting Them All

May 4, 2006

i'we tried for years to duplicate multiple movie clip and then hittesting them all but i can't this is my last resort

View 2 Replies

ActionScript 3.0 :: Hittesting MovieClip Class Array

Oct 29, 2011

I am trying to make a basic game, and have read all about bitmaps, but they have only confused me, so I am trying to succeed with a more flawed, but basic approach. I couldn't find any comprehensible tutorials on this, so I've tried it on my own, but it doesn't work.Basically I have my character in a movie clip connected to a class, and it is spawned when the movie starts, just like the "wall" class here. It populates the stage with a line of boxes, but my problem is that the hittesting only works on the first one.[code]

View 9 Replies

Professional :: Multiple MovieClips Loading SWF From Same Array?

Jun 14, 2010

I'm currently working on a project that has eight separate movieclips (for loading content) on separate layers.  I have placed code in these mc's to randomly draw from the same array of 61 different swf's.  Each mc randomizes the array just fine, but here's the problem.  The code works great for one instance, but as soon as I add the code (including renaming) to the other mc's, the swf won't load/play.  I am not getting an compiler errors, and am kinda stuck as to what the problem may be.  Here's an example of the code I'm using.  It is the same for each mc, except I'm renaming the variables as well as the instances for each mc.

[Code].....

View 3 Replies

Actionscript 3.0 :: Array For Hiding Multiple Movieclips?

Dec 4, 2010

I have the following simple code that functions just fine. What I would like is to be able to use the first three linesybutton1.visible=false;mybutton2.visible=false;mybutton3.visible=false;) and group them into an array or something so I can have that run within the functions showImage1,showImage2 and showImage3 without having to write it out each time like I've done belowHaven't really used arrays, so not sure how to do it.

Code: Select allmybutton1.visible=false;
mybutton2.visible=false;
mybutton3.visible=false;

[code].......

View 4 Replies

ActionScript 3.0 :: Creating Array Containing Multiple Library Movieclips

Mar 2, 2011

I'm trying to create a game where coloured items can be matched to coloured pegs on a washline but am having trouble with creating an array thet will place the pegs onto to the washline. I have 6 pegs and I wish to randomly attach 3 of them onto the line each time the swf is played.
 
Currently the pegs are labeled :
Blue_peg
Pink_peg

[Code]....

View 3 Replies

ActionScript 3.0 :: Multiple Images Loaded Into Movieclips Placed In Array?

Nov 13, 2009

I am trying to build a image-gallery-type picslider class. I have a playlist.xml whose architecture should be clear from the URLLoader stuff in my code. What I aim to do is to load 3 initial images into MoviClips and place the three in an array.Then, I'll manipulate the array to allow the user to flip left or right between images, while loading others offscreen.What I am hiving trouble with is loading multiple images into MCs using the Loader object inside a loop. When I run the code below, only the last image loaded appears inside a MC on the stage.Do I need to dynamically create loaders for each iteration?

Code:
package
{
import flash.display.*;[code]......

View 5 Replies

Actionscript 3 :: Store And Compare Multiple Movieclips Array Values?

Jul 9, 2011

I am creating a card game application in that dynamic movieclips created on stage and inside those movieclips different cards can drop, which have some values.

If one movieclip contains one card and another movieclip contained two cards and all the other movieclips 3rd,4th,5th.. etc contains some cards then, if i want to go back and want to drop another card at the top of the old one, than how i can do this, because when i go back and drop a new card inside movieclip than it replaces the old one. i don't want to create a new array for each movieclip.

View 1 Replies

ActionScript 3.0 :: Adding Multiple Movieclips To An Array (in One Line Of Code)

Mar 6, 2009

Code:
var menuArr:Array = [home_mc, menu1_mc, menu2_mc];

when I iterate with a for loop to add event listeners

Code:
var i:uint;
for (i=0; i<menuArr.length; i++)
{

[Code].....

View 4 Replies

ActionScript 3.0 :: Flash For Loop Loading Multiple Images Into Multiple Movieclips

Feb 5, 2012

[Code].....

I have a group of 16 images that I would like to load 1 of each into each movieclip. I want image1 to be inside of visual1, image 2 inside of visual2, and so on. the images are named like, 1960s_(1).png where the 1960 (year) part is coming from the rangeNum variable. The above gives me this error: 1061: Call to a possibly undefined method addChild through a reference with static type int.

View 4 Replies

ActionScript 3.0 :: Loading Multiple Images On To Multiple Movieclips?

Sep 16, 2009

I have 50 images that need to be on stage, which will be embedded into 50 different movie clips. I named the movie clips image1-image50 and the images are in an external folder named 1-50. Every freaking article or tutorial I have found clearly explains how to upload one image, or just one at a time. I can do that, and spend 2 days renaming all the functions, but I do not want to do that. Is there a better way to just load all 50 images, place them accordingly?

View 3 Replies

ActionScript 3.0 :: Load Multiple Images Into Multiple MovieClips?

Oct 26, 2009

I have 24 movie clips on the stage: my_menu.image_holder_mc1 thru my_menu.image_holder_mc24. I want to load an image in each one. How do I identify the holder which to add a child.

The Code I have so far is....

Code:
for (var i:Number=1; i<=24;i++){
var myLoader:Loader = new Loader();
myLoader.name = "image_"+i;

[Code].....

View 2 Replies

Array's And MovieClips - Use The Naming Conventions Of An Array?

Nov 18, 2009

I received help on this site on this info-graphic im doing and the solution was to use an "array" which im not familiar with at all. the person that helped me added the following code that worked:

var city_arr:Array = new Array("louisville");//filll that array with all nedded cities//make all the boxes invisible at startfor (i=0;i<city_arr.length;i++){    var [code]...

since i dont know how to use arrays im stuck. i need to add at least 30 more cities to my info-graphic but don't know how to use the naming conventions of an array.Only one of the houses works (when you click on it a pop-up appears, is draggable and has an x to close the pop-up)

Attachments:
relocation_working.fla.zip (975.1 K)

View 1 Replies

ActionScript 2.0 :: Hittest With Multiple Array - Without The Rest Of The Array Numbers Being Reset

Mar 20, 2009

The Setup: For each movieclip the hittests a set of "target" movieclips an array is given a value. If mcIcon1 is dropped onto mcTarget1 the first number in the vacant array is given the value of one. The Issue: If I remove mcIcon1, for example, from the mcTarget1 movieclip I can't find a way of just removing the 1 from that array without the rest of the array numbers being reset.

[Code]...

View 9 Replies

ActionScript 3.0 :: E.target For Hittesting?

Nov 9, 2009

I have a question regarding hittest object in actionscript 3. When using events, you can check what the current target is by using e.target or e.currenttarget. I was wondering how this achievable by hittesting?since hittests are not a function.

I need to retrieve info about the hittested object.Here is an example to make it more clear:

ActionScript Code:
if(movieclip1.hitTestObject(movieclip2)){
textfield.text = "this is information selected by the hittest: " + channel[e.target.name].item;
}

I'm working on a project and using hittest to navigate. So it's pretty important haha.

View 0 Replies

Hittesting Odd Shaped Objects?

Sep 8, 2009

I created a .PNG in Photoshop (see attachment) -- now when I make this into a movieclip the bounding box covers the entire area so the hittest activates as soon as my helicopter flies into the bounding box.I looked at adobe's "help" they recommended this code (by the way, I'm using Flash 8):

my_mc.hitTest(x, y, shapeFlag )
my_mc.hitTest(target)

The way I interpreted the code was like this:

onClipEvent(enterFrame){
heli.hitTest(248.1, -38, shapeFlag)
}

I read somewhere that you only use one of the two, and the shapeFlag one is the one to use.The above code I placed into the helicopter MC (named heli) - I set the x & y to where the PNG is.The PNG moves towards the helicopter, so I'm not sure if that makes a difference.I just want that if the helicopter runs into the ceiling or floor, the level resets.However my current actions activate as soon as it hits the bounding box.This is my code in the PNG:

onClipEvent(enterFrame){
this._x -= _root.levelSpeed;
}[code]....

I've tried a lot of things, and nothing seems to be working.

View 5 Replies

ActionScript 2.0 :: Hittesting Two Or More Buttons?

Aug 12, 2003

iv gotten hittest to work on me and my friends sites, but with olny one button for the MC to check for. Very simply, how do i get it to check for 2 or more?

View 6 Replies

ActionScript 2.0 :: HitTesting MC's From Library?

Sep 5, 2010

I've got a game where I need the enemys to hitTest with each other, I'm going to have copys of 3 types of enemys on the stage, instead of giving them all an instance name is it possible to hittest from the libary because I've given them instance names in the library of "enemya" "enemyb" "enemyc"

The code I have got didn't work which was -

Code:

onClipEvent(enterFrame){
if(this.hitTest(_root.enemyc)){
trace("true")
}

[Code].....

View 5 Replies

ActionScript 2.0 :: HitTesting A TextField.prototype?

Aug 23, 2009

I'm looking to run a trace that targets all TextFields on a mouse over, something like this:

PHP Code:
TextField.prototype.hitTest = MovieClip.prototype.hitTest;
onEnterFrame = function(){

[code].....

View 2 Replies

ActionScript 2.0 :: Hittesting. Special Rules?

Apr 23, 2006

are there any special rules regarding hittesting? im using this code here and its jus not working at all:

var speed:Number = 0;
var angle:Number = 0;
var angleFish:Number = 0;[code]....

im starting to get quite irritated

View 2 Replies

ActionScript 2.0 :: Array.onPress - Add A OnPress Event To Dynamically Duplicated MovieClips ID's Stored In Array List

Apr 15, 2011

lets say i have dynamically duplicated movieClips ID's stored in array list. i want to add a onPress event to them. how do i do it?

[Code]...

View 5 Replies

ActionScript 3.0 :: Hittesting 1 Fat Sprite Or Many Smaller Sprites?

Jan 6, 2011

At first I had all my sprites in an array and cycled through them to detect for collisions but now I am trying to put them in 1 big sprite and testing just that. I don't know if I am doing something wrong or this is to be expected but testing for 1 big sprite creates lag within the engine. Am I correct to assume that it's because I am constantly testing the pixels of the 1 sprite? When cycling through the sprites individually i never noticed this lag.

View 0 Replies

ActionScript 2.0 :: Shapeflag HitTesting Not Working In Movieclip?

Mar 19, 2008

I thought maybe I had to use localToGlobal, but they are on the same layer, so it can't be that. It works on the root frame, just not in the movieclip.

View 2 Replies

ActionScript 3.0 :: HitTesting Between Two Arrays Of Differing Length?

May 5, 2009

I'm just learning so I'm sure I'm making many stupid errors. How do you hitTest 2 separate arrays of different lengths, all entries against one another . Code below for guidance.

Code:
package{
import flash.display.*;
import flash.events.*;

[Code]....

View 2 Replies

ActionScript 2.0 :: Hittesting Movieclip With Movement Inside It

May 11, 2010

I'm making a game where your character must touch rings (big ovals) that are moving up and down with a motion tween (with easing). I attach these movies and push them into an array. For the hittesting, nothing is accurate. Since a movieclip inside the ring movieclip is moving up and down, the boundary box is much bigger than it should be when hittesting. If I use the x/y method, it triggers the hittest when my character is in line with the reference point. It should trigger when the middle of the character hits around the middle of the ring.

View 2 Replies

ActionScript 3.0 :: Hittesting Irregular Shaped Objects?

Dec 16, 2010

What I'm trying to do is hittest two irregularly shaped objects using their alphas and not the bounding box.

The code below hittests two objects named target 1 & target 2. This is not my code, but mine looks exactly alike, except target 1 & target 2 are replaced with my MC's. the thing is, I keep getting an error.At every function line, like the "public static function complexHitTestObject I get an error that says: Expecting right paren before left-bracket. I don't know what this error is caused by, because I can't really see why Flash wants another right paren.

[Code]...

View 6 Replies

ActionScript 2.0 :: Advance HitTesting - Test The Collision If They Are Rotated?

Oct 27, 2006

it's easy to test collision between two squares. how do I test the collision if they are rotated?

View 1 Replies

ActionScript 2.0 :: Accurate HitTesting Updating Arrays With Collisions.F8 CS3.zip?

Apr 25, 2008

I have 4 ball movie clips, a playhead and four target movieclips called mc_1-4, the array, (my_array), has 4 elements, which are each defined as having values of 0: I have a hitTest set up that will trace my_array to the output window each time it hits mc_1, to see what is happening. However the hitTest prints the array 3 times?

Am i right in thinking that this is because the hitTest is being triggered on entry of mc_1 in the center and upon exit?I need to make this hitTest be triggered once when the hitTest passes the center of mc_1. Secondly if any of the balls have been dragged and dropped on to mc_1 i want the array value with an index of 0, to change to 100 from 0 (not in terms of its index position because my array is only 4 elements long, in terms of its actual value) which i have tried to implement but i cannot configure the right code.

1. hit tests that only trigger once when they pass through the center of the object thus tracing one array.

2.use the balls 1-4 to make the array index 0, have a value of 100 if they are in contact with mc_1.

View 4 Replies







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