ActionScript 3.0 :: Faulty HitTest - Detect A Hit On The Image When It Doesnt Hit It?

Dec 20, 2010

I am have a enemy with a sword on 1 image and a player character on another.I test to see if the tip of the enemy sword (point) appears in the player image.
It seems to always detect a hit on the image when it doesnt hit it. The player image has a lot of transparent pixels and it looks like it detects a bounding box hit.Not sure what to do here as this test looks faulty. The y values are correct but the x values seem to cause th issue where xVal is the currect image x value.
 
x=enemy.xVal+el.x ;y=posY(enemy.yVal-el.y) ;
 
if (myplayer.img.hitTestPoint(x,y,false)==true)

View 8 Replies


Similar Posts:


ActionScript 2.0 :: Detect Hit To Bridge Via HitTest

Sep 28, 2011

0 down vote favorite share [fb] share [tw]

I have a silly problem with Flash (Actionscript 2) and that is:

i want to detect hit using hitTest function when the circle hits to the borders! but i could not! :|

Code:
import mx.transitions.Tween;
var myTween:Tween = new Tween(circle, "_x", mx.transitions.easing.None.easeNone,Stage.width/4, Stage.width-50, 50, false);

[Code]...

The Fla and Swf can be downloaded from Here: mediafire.com/?r045d2ehlbwgvsh

i.stack.imgur.com/iA2Mz.png

View 0 Replies

ActionScript 3.0 :: Detect A HitTest With The Cursor?

Feb 1, 2008

The current problem is trying to detect a hitTest with the cursor. I use this code very successfully in AS2, when I cannot use an rollover for whatever reason.

This is my AS2 code:

PHP Code:

onEnterFrame = function(){   if(my_mc.hitTest(_root._xmouse, _root._ymouse))   {      race("the mouse is positioned over my_mc")    }} 

This is me trying unsuccessfully to convert it to AS3:

PHP Code:

stage.addEventListener(Event.ENTER_FRAME, intro); function intro(e:Event):void{     my_mc.hitTest(mouseX, mouseY)     {        trace("the mouse is positioned over my_mc")     }} 

View 8 Replies

IDE :: Faulty 3D Transformation - How To Improve

Jan 31, 2009

I'm playing around with Flash CS4 trial and tried to 'compose' a 3d Box by putting 6 MovieClips as the side elements of the box in one clip which represents the whole box. (only using the Flash Tools, no Actionscript). Within the BoxClip (after doubleclick on the BoxClip on stage), all sides look right, each side is positioned with the correct angles and coordinates. Outside the BoxClip, back on root stage, the box sides are not parallel anymore, the angles are not 90 degrees, there is no 'box' actually. So I guess, one of the problems is the 3D Center point of the objects which is absolute to one point in coordinate space. The other problem is the faulty '3D' display in Flash, that is, changing from inside to ouside a clip changes the view also. So far, the Flash GUI seems quite useless for doing some '3D'. How to improve the workflow?

View 3 Replies

ActionScript 2.0 :: Use HitTest With Two Movieclips To Detect Collision Of The Visible?

Dec 12, 2002

Does anyone know how to use hitTest with two movieclips so that it would detectthe collision of the visible part of the MC, not the **** bounding box???

View 2 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 :: 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 :: Use HitTest To Detect If A Dragged Clip Is Over Any One Of 3 Different Targets?

Jun 20, 2007

I'm trying to use hitTest to detect if a dragged clip is over any one of 3 different targets - when it is I want that target to blink. And then when I drag off I'd like the blinking to stop. Make sense? I'm struggling a bit with the following code:

Code:
square_mc.onPress = function() {
this.startDrag();
for (z=1; z<4; z++) {
circle = _root["circle"+z+"_mc"];

[code]....

The "eval(circle)" part isn't really working.

View 4 Replies

ActionScript 2.0 :: HitTest - Detect Collisions Between Movie Clips And A Line

Nov 26, 2004

How do I detect collisions between movie clips and a line created through actionscript (with the lineStyle, lineTo, etc. commands). I tried making the line inside a movie clip and doing a hitTest with that movie clip, but it did nto work.

View 1 Replies

ActionScript 3.0 :: Change The Image Of A Mc, Why Doesnt It Inherit The Other Variables?

Feb 19, 2009

I've got a bunch of mc's which I've put in an array. With these mc's you can do a lot of different things, like dragdrop and rotation. I also got a button which on mouse down, changes the image of the mc. It only changes the image.. not the size. So far so good...But when I've clicked the button and the mc's all change their image... They are not able to dragdrop / rotation anymore. I do not understand why this is happening... because by clicking that button... it doesn't change the names of the mc's.....here is the code:

ActionScript Code:
library = new mc_library();
library.x = 100;[code]....

View 1 Replies

ActionScript 3.0 :: Load Movie Doesnt Unload Current Image?

Oct 19, 2009

The code works but with an issue. When I load an image it replaces the current one loaded but when I alpha tween the image to zero I see both images fading out on top of each other like the first one is still loaded but underneath the current one. Any body run into this before?

var imageLoader:Loader;
function loadImage(url:String):void {
// Set properties on my Loader object

[code]....

View 6 Replies

IDE :: Using A HitTest To Make A Thumb Menu From An Image Gallery

Jun 29, 2009

I'm having an issue with using a hitTest to make a thumb menu from an image gallery I'm working with move up and down. Basically I need to use a hitTest because there is a conflict with the other rollover functions in the menu itself that prevents me from using a simple onRollOver function. All I want to do is hide the menu until the mouse rolls over it then I want it to pop up then on roll out hide itself again. The gallery is part of a larger site that loads the gallery into the index page and has a full screen function so it needs to stay at the absolute bottom of the page just above the footer at all times. Here is the code I'm working with but think I'm over complicating it.

[Code]....

View 13 Replies

Actionscript 3 :: Detect Certain Image In The Clipboard?

Dec 9, 2011

Is there a way to detect if an image from a folder was copied to the clipboard?

View 1 Replies

ActionScript 3.0 :: How To Detect Collision Of Image Child

May 17, 2011

My collision detection is solid when I put 2 images against each other but when I put 1 image against another image's child I can't get a collision. Whats the deal? Do I have to add the child independently of its parent?

View 3 Replies

ActionScript 2.0 :: Detect Image Load Then Get Its Dimensions?

Aug 21, 2003

I am trying to load an image from an external source and then get the _x _y _height and _width of the movieclip that I have loaded the image into.

I have successfully loaded the image into a movie clip but because of the way Flash works I can not pull up the attributes of the movieclip.

View 10 Replies

ActionScript 2.0 :: Detect Image Load Complete After LoadMovie()

Sep 10, 2009

I use attachMovie() to create a new instance of a movieclip, then I use loadMovie() to load an external PNG image into the new movieclip. That is working fine.

I want to be able to detect when the image has finished loading into the movie clip container. I need to detect this because I want to check the image width and height.

If I check the width and height right after I call loadMovie() it is returning the default placeholder size, instead of the new loaded image size. It obviously has not finished loading when I check it there.

View 1 Replies

ActionScript 3.0 :: Photo Viewer - Any Way To Detect Broken Image?

Jul 16, 2010

I am using Flex to create a sort of photo viewer that loops through an array of photos when users click on arrow buttons. However, I wanted to make it so if an image is broken then it would be skipped, but I can't seem to find a way of checking if the image is broken.

View 3 Replies

ActionScript 1/2 :: Detect Image Load Complete After LoadMovie

Sep 10, 2009

I use attachMovie() to create a new instance of a movieclip, then I use loadMovie() to load an external PNG image into the new movieclip. That is working fine.I want to be able to detect when the image has finished loading into the movie clip container. I need to detect this because I want to check the image width and height.If I check the width and height right after I call loadMovie() it is returning the default placeholder size, instead of the new loaded image size. It obviously has not finished loading when I check it there.I am using ActionScript 2.0 but I can use 3.0.

View 1 Replies

Actionscript 3 :: Detect And Erase Specific Pixels From An Image?

Feb 17, 2010

Is it possible to detect (dynamically) the white pixels of an image and delete them? Actually i have some images that i load on stage but they are square without the actual image be a square sized. So i want to make the hit area exactly the shape of the image and not the whit border they have.

View 2 Replies

ActionScript 2.0 :: Detect Image Load Complete After LoadMovie()?

Sep 10, 2009

I use attachMovie() to create a new instance of a movieclip, then I use loadMovie() to load an external PNG image into the new movieclip. That is working fine.

I want to be able to detect when the image has finished loading into the movie clip container. I need to detect this because I want to check the image width and height.

If I check the width and height right after I call loadMovie() it is returning the default placeholder size, instead of the new loaded image size. It obviously has not finished loading when I check it there.

View 3 Replies

ActionScript 3.0 :: Detect Width And Hight Of Image Loaded From XML

Apr 26, 2010

I am loading images from XML and i want to detect its height and width [code]It shows 0 ... how can i trace the actual width and height of images?

View 2 Replies

ActionScript 2.0 :: Detect Broken Image Links Before Loading On Stage?

Nov 13, 2006

I've just finished a flash projector for my company's lobby that displays all members of the staff in a dynamically generated grid with a page for each department. Flash reads an xml file generated from our Active Directory using php.

I've just discovered a bug. We have several employees that don't wish to have their images displayed; the autogenerated path to their images are therefore false. When the screen loads, a blank space appears where the movieclip is supposed to load.

How do I detect that the image link is bad (must be simple as flash gives out debug errors)? I would like to load an alternate image for staff with missing images.

Here's a snippet of where the movie clips are generated:

Code:
for (i=0;i<nodes.length;i++) {
attachMovie("container", "new"+i, i, {_x:xPos, _y:yPos});
//load the image from the xml nodes array
this["new"+i].photo.loadMovie("images/staff/"+nodes[i].attributes.photo);
}

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

Flex :: Detect Screen Size To Center An Image On A Mobile Device?

Nov 23, 2011

Tried stage.stageWidth and stageHeight on applicationComplete, but for some reason the actual numbers returned do not seem to be accurate - the image always appears off-centered (stageWidth/2 - imageWidth/2). How do you determine the mobile device's actual screen size, to center an object?

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

ActionScript 3.0 :: URLRequest Doesnt Contain Anything?

Oct 20, 2009

I have an xml file which contains multiple products each with their corresponding background image, foreground image, text and website. The LoadXML class loads this xml file and creates an array of each image, text and website. The Main class then loads each image from the array of background images in the method onBackgrLoad(). This is done through the use of a for loop which loops through the array of backgrounds (called hintergrund[]) and loads each one in turn. On tracing hintergrund[] I sucessfully receive a string of all the different background image paths. However when I examine the backgrRequest and backgrLoader they both contain null. The images therefore dont appear on stage but neither does an error message appear! The same thing happens for onImageLoad (this should load the foreground image) and onTextLoad.
 
public class Main extends Sprite
{
//____________________________________________________________________________Vars : Newly

[code].....

View 6 Replies

IDE :: Play() Doesnt Work?

Mar 29, 2009

i made a slider that can slide the main timeline while running the swf.the first function slides scales the bar and moves the handle along the path:

Code:
sliderF = function () {
this.onEnterFrame = function() {

[code]....

View 3 Replies

ActionScript 3.0 :: External Swf Doesnt Replay?

Apr 19, 2010

I have a gallery of sorts and some images have a button that loads an external swf in a 3d tilting window. The problem that Im experiencing is that one of the external swfs does not replay upon pressing the button again--It loads but does not play--it was written in as2 and has some _global variables set. I was thinking that if I unloaded the the loader content and removed the loader from the display list that when it reloaded it would play again but it doesnt--This is the code Im using to unload and remove the child:

Code:
imgLoader.unload();
//imgLoader is the Loader

[code].....

View 5 Replies

Preloader Doesnt Work After Cacheing?

Jun 30, 2009

I have an app with a preloader - works fine until the content gets cached, then for some reason wont progress to the next slide - Fullscreen mode is set to full (if that makes a difference). It doesnt seem to happen consistently either.

[Code]...

View 1 Replies

Flash Doesnt Work On Nfl.com Video

Jul 12, 2009

ok flash doesnt work on nfl.com video.i got the new player 10 point whatever.tried it in mozilla all i keep it video loading.NEVER LOADS tried it in IE says i need to download the newest player from adobe already done.i took down my firewall setting took adblock plus off.

View 1 Replies







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