ActionScript 2.0 :: Hittest Only Works Once?

Jan 26, 2010

when i make this script:

onEnterFrame = function(){
if(ss.hitTest(_root.c2)){
_root.ss._x = -49.4;
}
}

it only does go to cords -49.4 once, after ss have hit c2 once it doesn't react when it hits c2 again!

View 9 Replies


Similar Posts:


ActionScript 3.0 :: HitTest Works But Also Returns Error

Sep 5, 2009

Perhaps I should leave well enough alone, but it bugs me that my hitTest gives me an error message even though it seems to work as intended. I have two movieClips running side by side. The second clip, the hitTest object is actually in an array that I keep pushing every second.

[Code]...
 
I have tried to trace cars[i].name and it returns "instance XXX" instead of what I would have expected, which would have been something like cars1, cars2, etc... If that is creating the error, I don't know how to fix it. I have thought also that perhaps the array itself is being referenced, but again I wouldn't know how to change it.

View 11 Replies

ActionScript 2.0 :: HitTest Function Only Works On Y Axis

Oct 14, 2003

My hitTest function only works on the y-axis
This is the code....
onClipEvent (enterFrame) {
// _root.speed = speed;
if (Key.isDown(Key.UP)) {
speed += 3;
[Code] .....

View 1 Replies

Flash8 HitTest Works Wierd With Rotating Objects?

Dec 29, 2009

How would i make hitTest work better with a rotating object(AS2). Becase i have a circle and it if gets near the rotating object (actually pretty far away) it starts the script,(new x and y)

I think thats the rotation script, becuase i took a break for like 4 days becuase it was irritating.

View 1 Replies

ActionScript 3.0 :: Perform A HitTest That Only Works On Children With A Certain Depth?

Feb 27, 2012

I have a problem with the getChildIndex() method. I have an array that stores multiple children and I want to perform a hitTest that only works on children with a certain depth, with one that is lower than the other hitTest "partner". Therefore I want to check the depth of that certain child.I tried to trace the depth, but I get crazy errors doing that. No matter if I do it from the child itself, or from the Document Class.

trace(getChildIndex(foes[7][1][1]))

[7] is the current level, [1] is the type of child and the second [1] is the child itself called [Object EnGob]. I put it there by the push() command.

View 3 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 2.0 :: Hittest - MC Movement Works Only When The Y Position Of The Mouse Is Over The 300 Px?

Jan 21, 2004

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.

[Code]....

View 1 Replies

ActionScript 2.0 :: Create An "hitTest" Script Inside A Movieclip That Is Actually Part Of That HitTest Code?

Jan 15, 2009

i just would like to know how to create an "hitTest" script inside a movieclip that is actually part of that hitTest code?I mean... I have mc A, and mc B. and the current hitTest code im using (that is on the timeline) makes mc A, destroy mc B when collide with it... but there are many mc B on the stage (with the same instance name) so, when mc A collide with one mc B, it destroys ALL mc's B... but i want it to destroy only the mc B that he collides, not all the others... maybe an hitTest script inside a movieclip B would work (somethig like "if MC A hitTest ME = i die" (not all the others)).

View 1 Replies

ActionScript 3.0 :: Movie Clip ROLL_OVER Only Works Once But MOUSE_OUT Works Infinitely

Apr 11, 2011

I have a movie clip (with instance name rectangle_mc) on the stage. Within this movie clip there are two separation animations on the timeline. The ROLL_OVER animation starts on frame "over" and the MOUSE_OUT animation starts on frame "off." If I roll over the movie clip, the initial animation plays, and when I mouse out the other animation plays to restore it to it's initial state. However, once the rollover animation has played once, it will not play again when I roll over it again, but for some reason the MOUSE_OUT plays every time.

[Code]...

View 1 Replies

ActionScript 3.0 :: Do Something After Hittest " Remove Hittest After First Collsion"?

Feb 8, 2010

i am controlling a tractor mc with right and left keyboard keys and let the user move the tractor till it reach a certain point where it touch a mc i want to go to a certain frame and stop the keyboard event listener and also the hit test listenerso finally the tractor is moved by user till it touches the mc then we will jump to a certain framethis certain frame will not have both of the tractor and the mcPHP Code:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.MovieClip;

[code].....

View 1 Replies

HitTest On Multiple Mcs?

May 14, 2009

I have a movie clip called frog who moves along the screen, I want him to jump when he hits any other movie clips. I can make him do so with the code below, the problem is that if I write the same function for the other movie clips it doesnt work, it still works on the first one but none others. I have tried attaching an onCilpEvent on both the frog and on all the other movie cilps so no avail.
 
function hitBaby(){
if(_root.babyWord.hitTest(_root.frog)){
_root.frog.gotoAndPlay("frogB");}else{  _root.frog.gotoAndPlay("frogA");}

[code]....

View 3 Replies

ActionScript 2.0 :: Set Depth On A Hittest?

Feb 25, 2009

i have this drag and drop thing basically when i drop the item on top of its slot i want it to do a hittest to set the depth to a number assigned to it. so lets say I drag an item called Item to a spot called slot i want it to do like item on hit test to slot set depth(2) lets say.

View 1 Replies

ActionScript 3.0 :: Hittest Is Not Working

Apr 7, 2010

i'm trying to build this simple game for school: you've got a catapult which launches a "bullet" and you will have to aim it to hit a certain point. Now the whole catapult part and shooting the "bullet" works, but now it has to respond when it hits something, and that's where i'm stuck.

[Code]...

View 1 Replies

ActionScript 2.0 :: HitTest Is Not Working

Aug 12, 2010

I'm trying to make a hitTest between to movie clips (Let's call them J and T)[code]But nothing happens when the two movie clips collide.

View 5 Replies

ActionScript 3.0 :: HitTest : Can't Get It To Work

Mar 17, 2011

I am trying to create a game. My game is birds eye view game and I am trying to get it so my character (instance name hero_mc )can't pass through the buildings(instance name block_mc). I have been looking at tutorials on the web and most of them cover it so that a text appears if you hit the object whereas I want it so my character can't pass through or well is "push back", the one tutorial I found doesn't want to work for me, but it's not giving me any errors so I really don't know what is wrong with it.

Actionscript Code:
hero_mc.addEventListener(Event.ENTER_FRAME, enter_frame); function enter_frame(event:Event):void{if (hero_mc.hitTestObject(block_mc)) { trace("hero _mc is next to block_mc") } else { hero_mc.y += 10  hero_mc.x += 10  } }

My character still passes through the block objects.

View 1 Replies

ActionScript 2.0 :: CS3 To HitTest Within An Array?

Jul 22, 2011

I have this thing where orbs are supposed to stick together, so I put them all in an arrayand told them to stick together when they encounter another member of that array.However, they only stick in groups of up to four, and then the orbs begin to overlap and such.

View 2 Replies

Using Hittest And Attaching Sounds?

May 12, 2009

I am working on a game that involves a play head (called playHead) moving along the screen and when it encounters various movie clips it triggers a sound to be played. It is all going well except that the sound seems to want to play more than once, so there is a staggered wierd sound. Is is possible to make the sound only play once and also it needs to play until the the sound has finished. (the sounds are all very short).Here is the code:
 
onClipEvent(enterFrame){    if (this.hitTest(_root.playHead)){            _root.sound15.stop();    _root.sound15.attachSound("over");    _root.sound15.start();            }       }

View 5 Replies

HitTest Was Playing The Sound Over And Over?

May 20, 2009

I have a playhead that moves across the screen and when it hitTests a movie clip it plays a sound. all is working fine except that it will only work the first time it is played. The playhead is controlled by a button. I am working in Actionscrpt2. Here is the code on the movieclip:

onClipEvent(enterFrame)[code]....

In the begining I was having trouble because the hitTest was playing the sound over and over but the above code sorted that out. I think that the new problem was created by fixing the old one.

View 7 Replies

ActionScript 1/2 :: HitTest And Draggable MCs?

Aug 16, 2009

These codes are in the draggable MC: fish1_drag this is my code:
 
onClipEvent (enterFrame) {    this.onPress = function() {        startDrag(this);    };
_root.UI1_mc.UI1_mc2.inv_mc.ISpace1.onEnterFrame = function() {        if (this.hitTest(fish1_drag)) {            stopDrag();        } else {        }    };}
 
I keep jumbling it up so that one thing works but the other doesnt. But basicly I need it so that when I drag fish1_drag (instance name) over ISpace1 (which is within many MCs : _root.UI1_mc.UI1_mc2.inv_mc.ISpace1 but opens up so you can drag it over it) for it the drop on the ISpace1.
 
I have another MC in the library and il get that the attach to the ISpace1 but what im finding difficult is just being able to drag the fish1_drag over the ISpace1 and releasing.
 
Here is some other reandom code that I have in a comment on my AC panel:
 
/*
this.onRelease = function() {                stopDrag();                _root.UI1_mc.UI1_mc2.inv_mc.ISpace1.attachMovie("fish1_mc","attached1 ",this.getNextHighestDepth());                _root.invCount += 1;                updateAfterEvent();  // I probly dont need this updateAfterEvent. but its there anyway.            };
*/

View 3 Replies

ActionScript 3.0 :: Hittest Is Not Working?

Apr 7, 2010

i'm trying to build this simple game for school:you've got a catapult which launches a "bullet" and you will have to aim it to hit a certain point.Now the whole catapult part and shooting the "bullet" works, but now it has to respond when it hits something, and that's where i'm stuck.
 
I've included:
 
if (stok.kogel.hitTestObject(this.muur)) {           trace("ball hit")            }
 
but I just can't seem to get an trace back.(PS: here's the file as refference (all AS is in the catapult))

View 7 Replies

ActionScript 1/2 :: Perform HitTest Between Mc Within An Mc?

Aug 17, 2010

how to perform hitTest between mc within an mc??i tried it in the same timeline and it works, but those two movieclips (BLUE COLOR) is inside different MC'sis there a way to perform a hitTest between them??

View 3 Replies

ActionScript 1/2 :: GotoAndplay On HitTest?

Sep 8, 2010

I'm trying to make it so that when a movieclip (box) touches another movieclip (exit), it goes to frame 2.I've made it so that (box) moves with the arrow keys and doesn't go pat the barriers (boulders) using this:

x.onEnterFrame = function()
if (Key.isDown(Key.RIGHT)) {box._x += 5;}
if (Key.isDown(Key.LEFT)) {box._x -= 5;}

[code]....

View 2 Replies

ActionScript 1/2 :: HitTest The Same Movieclip?

Sep 4, 2011

_root["zombie"+i].onEnterFrame = function() {
if(this.hitTest(this)){
trace("hit!");
}
}
 
This does not work, it traces hit! even if none of the movieclips are touching. dont know how else I can do this.

View 9 Replies

Flash :: AS2 To AS3 HitTest Migration

Nov 20, 2009

I am stuck in as3 hit test problem. this is the code i wrote in as2. migrate this in to as3

[Code]....

View 2 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 :: Hittest On Multiple MCs?

Jul 7, 2011

I am running a hittest on an array of thousands of MCs a little a part, due to the nature of this sometimes two can be hit at once.How would I narrow it down so that the one which is hit the most is the one returned value?

View 1 Replies

ActionScript 2.0 :: Using HitTest For No-overlap?

Sep 22, 2006

I'm trying to use hitTest so that if any images overlap they will be replaced on the canvass.

ActionScript Code:
function imgSeed(){
for(i=0; i<5; i++){[code]....

although this works, It checks against itself, so it always true at least once, how can I tell it not to check against itself?

View 3 Replies

ActionScript 3.0 :: How To Use BitmapData.hitTest

Jul 11, 2009

Im making a simple game with destructable terrain. Therefore i use a bitmap for the ground and a movieClip for the player. When the ground is a bitmap i cant use regular hitTestPoint because of the bitmaps transparent pixels. So i looking i the livedocs for the bitmapData.hitTest but i rly dont understand all the parameters.So my question is. How can i reproduce this with bitmapData.hitTest?

ActionScript Code:
if(ground.hitTestPoint(player.x, player.y, true)) {
//actions

[code]....

View 3 Replies

ActionScript 2.0 :: Only Want HitTest To Work Once

Mar 30, 2010

I have this very simple .fla file and you use the keys to move the bus around. As it detects the hittests with the other movie clips on the stage it goes to and plays a frame on that mc's movieclip. It all works fine but i dont want the hittest to repeat after it has done it once(on each movie clip) so that as you drive the bus around you reveal the photo. [URL]

View 1 Replies

ActionScript 3.0 :: HitTest Between Two Classes?

Sep 19, 2010

My problem now is that i got two classes and one document class (document class just adds the two other classes to the stage).I want to have the two classes being able to hitTest with oneanother My two classes creates a number of randomly moving objects to be placed on stage (the two classes are identical, except for different name).Not sure if i go in the right direction for hittest at this point, but when i have tried to hittest one object with the other object, i just get "access of undefined property error". So i'm guessing i have problems referencing between the classes somehow.

View 2 Replies







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