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


Similar Posts:


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

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 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 :: Pulling Data From Class Array Onto A MovieClip?

Aug 6, 2009

I am trying to create this slide show application that will show product information (Tennis Rackets) based on diffrent categories. A great programmer advised me that OOP would be a way to go, however i am having a difficulty with it.
 
I created: A document class called CustomClass --> this class downloads all XML data from the server and pushing the content of it into Arrays based on a category.These arrays are public, there is also a funciton iterateArray which places the children information somewhere.

[Code]...

View 7 Replies

ActionScript 3.0 :: Controlling MovieClip Instances Via Array In The Document Class

Jun 25, 2009

I tried to take similar code from this same forum, but I was either getting an error 1118 or an 1009 (null object reference).

Basically I have a series of movie clip instances on the stage with instance names of:

number_1
number_2
number_3

[Code]....

I tried but I kept getting an error...I think I am a little confused as to how to make it work properly.

View 4 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 3.0 :: Create Movieclip Class That Subclasses Another Movieclip Class

Sep 3, 2010

I want to create a movieclip class that subclasses another movieclip class and inherits all its properties (rather than having to rely on the include statement). In my project I'm using:An abstract parent class that extends a movieClip: "infantryDroid".[code]However everytime I try this, flash acts as though nothing was imported from the parent movieclip class.If I was to try the above code I would get the message that _root and speed (which were defined in the parent class) "are undefined".

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

ActionScript 3.0 :: HitTesting Edges / Moving Movie Clips Stage Length?

Dec 7, 2010

This is sort of a multi-layered question- I have a movie clip that I sectioned off in quadrants:The red dot is the player, the stage is the size of one square. My goal is to, when the player moves to either of the 4 edges, the next section of the quadrant comes up (meaning if the player moves to the right edge, the section that borders the right edge will slide on screen, and the old section will slide off screen).I was wondering if there was a way to hitTest if an object is touching any part of the edges? Is the hitTestPoint method something I should look into? What I have so far is an object off screen (black rectangle), that when the player touches the quadrants slide like I want them to (at least I'm trying to make that work).Here is my code. I know some of it's wrong and/or I'm missing something.

if(leftKeyIsDown && player_mc.x > -15)
//-15 is half the size of the temporary player_mc
{

[code]......

View 18 Replies

ActionScript 3.0 :: Calling An Array In One Class From Another Class?

Oct 13, 2010

I'm trying to call a function in one class from another class and I'm using an array in the function of the class that I am calling from the other class. The array is declared and instantiated in the one class but when the other class calls the function with the array in it I get an error #1010: A term is undefined and has no properties. because the class that is calling the function that contains the array doesn't know that it is already declared. Anyway here is the code.
 
//CLASS THAT CALLS THE FUNCTION OF THE OTHER CLASS WITH THE ARRAY:
public class SpaceWolf extends MovieClip
{
private var _playerMissiles:PlayerMissiles;

[Code].....

View 7 Replies

Use Either Maintaining Movieclip Array Or Bitmap Data Array?

Jun 5, 2009

I am working on a project in which I am suppose to matain an array of movieclips, and I can also convert the movieclips into bitmap data. so I would like to know which one is the best to use either maintaing movieclip array or bitmap data array.

View 2 Replies

Actionscript 3 :: Can A Document Class Extend Another Custom Class That Extends MovieClip?

Aug 16, 2011

If I have a Document class that extends MovieClip, and I want to use it as the basis for another Document class, is it possible to create a subclass that extends the main document class and use that for a different FLA?

For example,

fla1.fla has a document class of MyMainClass:
public class MyMainClass extends MovieClip
fla2.fla has a document class of MySubClass:
public class MySubClass extends MyMainClass

I've tried, but now I'm getting errors that all of my variables that reference stage instances aren't being found.

View 1 Replies

ActionScript 3.0 :: Referencing A Textfield Inside A Movieclip Class From Document Class

Feb 3, 2009

Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.

I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().

I hate to be defiant, but what if I don't want to?

Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?

It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.

That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.

HERE ARE THE STEPS I'M TRYING:

- Create new flash document

- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage

- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()

- Set a name for that box using box.name = "test" let's say

- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great

- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";

That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?

View 1 Replies

ActionScript 3.0 :: 5000: The Class 'fla.class' Must Subclass 'flash.display.MovieClip'?

Jun 24, 2009

And i cant figure it out.the "my.fla.class"content looks like this

Code:
package my_fla
{

[code].....

View 2 Replies

ActionScript 3.0 :: Reference Movieclip On Stage From Custom Class Of Document Class

Dec 7, 2009

Is there a way I can reference a Movie clip I have on the main stage from a custom class of a document class?[code]

View 1 Replies

ActionScript 3.0 :: Call Function Of Document Class From MovieClip Class

Aug 8, 2008

How can I run function of the main document class from a class of a MovieClip? I usually just used MovieClip(parent).function(), but now my MovieClip has another parent. Or what do I have to pass to the MovieClip class when creating the MovieClip to acess the main document class?

View 9 Replies

ActionScript 3.0 :: Dispatch Event From Class That Isn't Extended Class Of MovieClip?

Oct 20, 2009

Is it possible to dispatch event from class that isnt extended class of MovieClip? I created my own class and put import flash.events.Event; import flash.events.*; but when i call dispatchEvent compiler throws error:"1180: Call to a possibly undefined method dispatchEvent."

View 3 Replies







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