ActionScript 2 :: HitTest Wont Work?

Sep 22, 2009

I was trying to make it so you had to hold up this ball, and if it touched the block near the bottom of the screen, it would go to the first keyframe. (The menu.) So, I labeled the ball, "ball", and the block, "block". Then, I added this code to the block:

onClipEvent (enterFrame) {
if (ball.hitTest(block)){
gotoAndPlay(1)[code]....

And tested it out. To my dismay, it didn't work at all. I've spent about 30 minutes testing other ways, and I cant seem to make it work.

View 6 Replies


Similar Posts:


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 :: 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 2.0 :: Can't Get The HitTest To Work

Sep 3, 2005

so my game's code is as follows:

Code:
//The Austin Weisgrau (El Nacho)
//Blob Game, to go with the video so it will get like the .3 mor it needs not to be blammed

[Code]....

the character instance is Blob and the background instance is Background. i can't get the hitTest to work with either of those two things in the /* */ and i need to no how i can

View 1 Replies

ActionScript 2.0 :: Cannot Get HitTest To Work On A Mc

Oct 14, 2008

For some reason I cannot get my hitTest to work on an mc within an mc within an mc...which is assigned to a variable...

Code:
var miniWin:MovieClip = CAD_mc_mini.zoomControl.miniWin;
trace(miniWin); //returns _level0.CAD_mc_mini.zoomControl.miniWin
var mouseListener: Object = new Object();

[Code].....

View 3 Replies

ActionScript 2.0 :: How Does Bitmapdata Hittest Work

Sep 23, 2009

import flash.display.BitmapData;
import flash.geom.Point;
//
var BitmapA:BitmapData = new BitmapData(550, 400, true, 0x00);

[code]....

This is using the bitmapdata.hittest way to check whether the one bitmap is overlapping the other. Throug pixel-to-pixel detection.But I'm having trouble understanding this line:

Code:

if (BitmapA.hitTest(destPoint, 255, BitmapB, currPoint, 255))

I know that destPoint is the topleft point from which it is determining all opaque pixels. No value is given to destPoint so basically it is checking from 0,0. Having determined all opaque pixels from that bitmap it should compare them with the opaque pixels of the other bitmap. But why does currPoint use the topleft coordinate of its movieclip? Couldn't it just as well use 0,0 too? I mean when determining the opaque pixels of bitmap two it might as well start checking for those from 0,0 as the topleft position as well?

View 2 Replies

ActionScript 2.0 :: Flash8 Why Can't Ever Get Hittest To Work

Mar 28, 2011

i am making a game where a ninja runs through a course, every thing is running smoothly. EXCEPT hittest will not work, hittest never works on ANY of my projects. I know im doing it right, because ive even tried copying and pasting working ones. Look at the attached fla file to see what im talking about.is it my computer that wont let it work, because the exact codes worked for all of the people on youtube that used it.

View 2 Replies

ActionScript 3.0 :: Hittest Will Not Work In Array?

Feb 18, 2009

I am trying to use the following code to simplify multiple Hittests using an Array, but the code won't work. Can anyone tell me why?

var blockArray:Array = new Array("block1", "block2", "block3");
player.addEventListener(Event.ENTER_FRAME, blockTest);
function blockTest(evt:Event):void {

[Code].....

View 4 Replies

ActionScript 2.0 :: How To Get Simple HitTest To Work With Two MCs (Lines)

Nov 30, 2009

I am having trouble getting a hitTest to work. My two MCs are lines, one horizontal, one slanted. When the horizontal line gets within the "bounding box" of the slanted line the hitTest is true, but it's not touching the slanted line yet. I saw that the shapeFlag property comes into play here, but only when using coordinates... I'm not sure how to apply it to these two lines. I want the hitTest to be true only when the lines actually touch. I have attached a simple FLA of the problem.

View 1 Replies

ActionScript 3.0 :: HitTestPoint - Hittest Doesn't Work?

Dec 30, 2008

I have this code so that when a spaceship goes through a blackhole it plays the spaceships moveiclip. This works fine on the first part of the code when the user just clicks the start button.However, i have put in a difficulty setting and when you change the difficulty setting the hittest doesn't work anymoreand there are no error messages. I have tried putting the blackHoles array in the difficulty function but nothing changes and i didn't really think this would make a difference as the easy function is already using the blackHoles array outside the difficulty function.

View 7 Replies

ActionScript 2.0 :: Hittest Doesn't Work Off The Stage?

Sep 13, 2009

I have about 100 movieclips that scroll across the stage from out of bounds. They are supposed to hit another movieclip both in bounds and out of bounds, but it seems like Flash only detects the hittest when it happens within the frame.

if(_root.sceneclip.reef1.hitTest(this._x+300, this._y+350, true) ){

View 2 Replies

ActionScript 2.0 :: Hittest Nor Other Method Doesn't Work

Aug 20, 2010

So I'm doing this project for school and all, and I'm trying to do a htitest on an object. For some reason, it doesn't work. So I tried writing out my own method... Which halff worked, but wasn't as exact as it should've been.

Heres my code (Though I'm pretty sure somethings wrong with my MC, so i'll upload the main .fla file)

Code:
right = true;
left = false;
itemX;
itemY;

[Code].....

View 1 Replies

ActionScript 2.0 :: Make E To HitTest F To Get Something Else Function But They Won't Work?

Sep 6, 2011

Lets say that I got movieclips A,B,C,D in my scene and E,F which only come into scene when A hitTest B and C hitTest D.I was able to make the A+B and C+D hitTest functioning properly. But when E,F came into the scene, I tried to make E to hitTest F to get something else function but they won't work.# note that there is some short animation before E & F come into scene.I am pretty sure all the instance names are named properly.

View 5 Replies

ActionScript 2.0 :: HitTest On Mc Doesn't Work With ScrollRect?

Oct 29, 2006

I have two pieces of code, that won't work together.First: this makes a hitTest on an mc to make it run on rollover:

Code:
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (this._currentframe<this._totalframes) {
nextFrame();

[Code]...

Each work seperately, but they won't together. How do I get around this?

View 7 Replies

ActionScript 2.0 :: Simple HitTest To Work For Rounded Walls

Mar 19, 2009

I've been trying to write a hittest that will work for rounded walls on my RPG. But I've been epic phailing.

Heres my code:
onClipEvent(load){speed=10;
}onClipEvent(enterFrame){if(Key.isDown(Key.UP)){this._y-=speed;this.gotoAndStop(5);
}if(Key.isDown(Key.DOWN)){this._y+=speed;
this.gotoAndStop(6);}
if(Key.isDo wn(Key.RIGHT)){this._x+=speed;this.gotoAndStop(7);
}if(Key.isDown(Key.LEFT)){this._x-=speed;this.gotoAndStop(8);}

View 2 Replies

ActionScript 2.0 :: HitTest - Setup In The Attached File Seems To Work In Relation With The Blue Box's

Nov 10, 2003

for some reason the hitTest I have setup in the attached file seems to work in relation with the blue box's that surround objects and not with the actually objects. Anyways I'm pretty sure that it has to do with the border.

View 4 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 :: 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 3.0 :: Dynamic Fonts Don't Work... But Arial And Verdana Work?

Mar 19, 2012

I am trying to defeat my psychological block with dynamically loaded fonts in AS3, and I have an annoying problem. I am creating a clock with a textfield and I am loading fonts from a SWF library: the available classes/linkages are "Arial", "ArialBold", "MyriadPro", "MyriadProBold" and "Verdana".This is the line where I get the class from the SWF, and it extracts the class correctly

Code:
clock = new Clock( { fontClass: assetsLoader.getFontClass("skin", "Arial") } );
The constructor...

[code]......

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







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