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


Similar Posts:


ActionScript 3.0 :: Detect Haven't Dragged The Movie Clip?

Mar 24, 2009

I have the standard drag and drop functionality setup with the MOUSE_DOWN / MOUSE_UP commands. However, if I just click on the item and decide not to drag, it still executes the commands like it was dragged. Is there any code I can put in so that if they decide not to drag the movie clip, the function doesn't fire?

View 3 Replies

ActionScript 3.0 :: Provide A Success Message (perhaps With A Dynamic Text Field) When The Three Objects Have Been Dragged To Their Targets?

Feb 27, 2012

How do I provide a success message (perhaps with a dynamic text field) when the three objects have been dragged to their targets?

package
{
import flash.display.Sprite;
import flash.events.MouseEvent;

[code].....

View 2 Replies

ActionScript 2.0 :: Multi HitTest Targets?

Jul 24, 2009

I am currently making a game involving matchsticks. i have the dragging of the matchsticks working. But now i would like to know how to check if 2 (or more or less depending on what level) of the possible matchsticks are dropped on the target. When the right matchsticks are drop in the right places i will put in an action like "gotoNextFrame" or make the continue menu visible.

View 9 Replies

ActionScript 2.0 :: Detect The Speed Of The Movement Of A Dragged Object?

Aug 30, 2004

I use something like this code to detect the speed of the movement of a dragged object

PHP Code:

if (!go) {
this["position_"+i] = this._y;
 i++;[code]....

This way I can find in what direction the mouse vertically has moved and at what speed. The problem is that every once in a while the speed will be in the opposite direction. What do people use to detect the direction of the movement of the mouse?

View 2 Replies

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

ActionScript 2.0 :: DropTest - Check And See If The Dragged Movie Clip Is Completely Within The Bounds Of Another Movie Clip

Jan 11, 2010

I'm creating a small drag & drop activity, and I want to be able to check and see if the dragged movie clip is completely within the bounds of another movie clip (or at least in the bounds of a certain x/y zone on the main stage. I can't use dropTest because it returns true if any tiny bit of the movie clip overlaps with the dropTest movie clip.

I also thought of something that just checks the x/y coordinates of the dragged movie clip, but I'd need this to reflect a range of values rather than one coordinate. For instance, I'd want to return true if the movie clip's x is between 50-60 AND the y is between 50-60. I'm attaching a small graphic to illustrate in case my explanation isn't clear enough [URL]

View 3 Replies

Movie Clip Used In One Fla Be Dragged And Dropped Into Another?

Apr 21, 2010

Can i create a custom text animation or something. Ofcourse without involving variables. And can i use this Movie clip in various projects. What am i supposed to do, save it and keep it as a .fla or can the movie clip alone be saved and imported into various projects ?

View 5 Replies

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

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 1/2 :: Load Movie Clip Once All Drop Targets Have Clips In Them?

May 10, 2011

When the the 1. , 2. and 3. lines have boxes dropped on them I want the movie clip to load. I haven't been able to achive this. but I found a temporary way around it by making the clip load once the "3." target is full. this works but isn't completly accurate, I need it to also check if the other targets are full before the clip loads. I'm thinking it's something like:

"if (demons_mc.hitTest("targetCircle3+targetCircle2+targetCircle1")){this ._parent.gotoAndPlay("join"); }"

View 5 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 1/2 :: Level For A Movie Clip - That Is Dragged To The Stage

Dec 30, 2010

Is there any way to set the depth level for a movie clip that is dragged to the stage, rather than created in Action Script.

View 10 Replies

ActionScript 3.0 :: Constrain A Dragged Movie Clip To The Stage?

Jul 1, 2011

I have a movie clip (pano_mc) that I can click and drag left and right. When I drag it to the right, it stops dragging when the left edge of the clip reaches the left edge of the stage. This is great!
 
When I drag the image to the left, the right side edge if the clip does not stop at the right edge of the stage, but continues to click and drag until it reaches the left edge of the stage.
 
I need the left edge of the clip to stop at the left edge of the  stage and the right edge of the clip to stop at the right edge of the  stage.
  
Here is the code I have so far
 
The pano_mc is registered to the top right corner and is 7024px in length. I know it is a bit large. The axis_mc is anchored to the upper left.

[Code]....

View 5 Replies

ActionScript 3.0 :: StartDrag()... Constrain Dragged Clip AND Mouse?

Jul 19, 2009

how to constrain the Mouse movement along with the MovieClip I am dragging. In the following example, if Mouse travels outside of the box, it stops responding to MOUSE_UP. I would like Mouse to be constrained to the same area as ball during dragging, that is, when ball reaches a boundary Mouse will stop as well.

ActionScript Code:
var box:MovieClip = new MovieClip();
box.graphics.beginFill(0xFF0000, .75);

[code]...

View 1 Replies

ActionScript 2.0 :: Graphic To Be Hidden Once A Movie Clip Has Been Dragged Over It?

Mar 14, 2007

I need a few answers and pointers for my game [URL] First off, is it possible for a graphic to be hidden once a movie clip has been dragged over it? The plan is for the grid to be covered in question marks, until the users drags the small smiley over the same large smiley at which point the question mark will be hidden revealing the large smiley. The user then gets a 2nd chance to match up the other remaining smiley, if they fail to get the right smiley is it possible for the question mark image to appear back over the top of the smileys?

View 5 Replies

ActionScript 2.0 :: Tween - Make A Button Trigger A Movie Clip That Targets Specific Coords?

Feb 22, 2005

how do i make a button trigger a movie clip that targets specific coords? I'm building a map and when a button is click it goes to a defined point. right now it jumps to the coords, but i'd much rather it smoothly move instead. the other thing is that i would like it to move from whatever point it is currently at.

View 11 Replies

ActionScript 1/2 :: Add A Code So Drag And Drop Movie Clip Will Not Stick  Once It Is Dragged To Final Place?

Apr 18, 2011

I have to use the old drag and drop code on my movie clips, but the problem is when I drag the movieclip to the area on my .swf file once i release it, it sticks to the hand mover.I am encloseing the action script I am using could someone or kglad tell me what is missing from the code so that once it is released it will not stick, see code belowcircle.onPress = function(){ startDrag(this);}circle.onRelease = function(){ stopDrag();}

View 3 Replies

ActionScript 2.0 :: HitTest Movie Clip Hitting Another Inside In A Movie Clip?

Mar 25, 2011

I have in my root:

1 Movie Clip instancied as a "cursor" 1 Movie Clip instancied as a "Mc_Obstacles" with others 5 Movie Clipsand the 5 Movie Clips inside the "Mc_Obstacles" are instancied as "Obstacle" , all with the same instance...I want this: when the mc "cursor" hit one of mcs "obstacles" gotoandstop to frame X then i did in frame with actions in another layer:

cursor.onEnterFrame=function(){
this._x=this.x+10;
if(this.hitTest(Mc_Obstacles.Obstacle)){
gotoAndStop(4);
}
}

View 1 Replies

ActionScript 3.0 :: HitTest With Movie Clip?

Sep 7, 2009

I'm making a droid (bad guy) move down the screen. If it hits the robot (good guy) the baseHealth will go down 2, same if it hits the bottom of the screen. If it hits the beam movie clip then it will go to the top of the screen and continue downward. The beam movie clip is a laser that slowly move outward, and I want the droid to go to the back of the screen if it ever touches any frame of the beam. However, when the droid touches the beam nothing happens, though it seems to work when it touches the robot or hits the bottom of the screen.

Code:
addEventListener(Event.ENTER_FRAME, moveDroid);
function moveDroid(e:Event):void{[code]....

View 1 Replies

ActionScript 2.0 :: Implement A HitTest With A Clip With FT Added?

May 1, 2003

Im 'TRYING' to use your FreeTransform proto from Layer51.com, with the drawing movie ive been making (for the last century lol) namely with lines using the draw api and duped circles (which have textfields inside)..

I think for my requirements I need 2 types of free transform, 1 for transforming lines, the other for transforming circles with text inside. It seems rotation with your FT kills the text inside my circle so I figured I would remove the rotation handles for one style. Also Im after;

1) manual control over FreeTransform as I only want it enabled when a user selects the 'transform' button in the tool bar (disabled otherwise)

-> so I have set 0 for autoRemove, so that I can addFreeTransform to all clips on 'moveComponents' (button clip) "down" event and removeFreeTransform on 'moveComponent's (button clip) "up" (ie not selected). Seem ok/logical?

2)Next I have a canvas, so I need selected elements to swap depths and be dragged BUT only in the canvas area,

-> Im not sure how to implement a hitTest with a clip with FT added?

3)Lastly Ive had an issue with using FT on clips with api drawn lines. It seems that the center cross hair is way up in the top left, and funnily enough the boundary (ie the surround handles bit) manages to perfect wrap itself around the line. Of course because the center cross hair is way up in the top left the rotation and resizing of the line is completely wacky.Anyway here's my 2 FT styles...

Code:
//My freetransform style for circles
ftCircleStyle = new FreeTransformStyle([3,0xFF0000,100], [15,0xFFEEAA,100], [null,"s",null,"s",null,"s",null,"s"], true, 0);[code]....

1)The AS you'll find in the timeline of the clip called 'drawArea'.

2)And to run the movie compile the fla and click the blue arrow on 'New' in the menu you see, then a toolbar will appear with a canvas.

View 1 Replies

ActionScript 3.0 :: HitTest For Multiple Movie Clip At The Same Time?

Dec 5, 2009

I have a movie it is a triangle.I duplicate it and I want to hitTest on the first triangle movie clip and I added 3 different line movie clips on the 3 side of triangle.I tried to write a code something like that.
 
if(firstTriangle_mc.hitTestObject(line1_mc,line2_mc,line_3mc){
trace("Ok");
}

but I've got error.I think it is not allowed hitTestObject for multiple Movie Clips.So is there anyone have an opinion about it?What should I do?

View 5 Replies

ActionScript 1/2 :: Hittest Multiple SAME Movie Clip Entities?

Feb 15, 2010

By using the attachMovie function, I create multiple entities of the same movieClip. Is it possible to detect collisions from the same, but multiple movie clips (And, with different Linkage Identifiers with each entity of the same movieClip.

View 3 Replies

ActionScript 1/2 :: Setting Up Hittest With Nested Movie Clip?

May 20, 2010

I am trying to set up a if function for a hit test. I am using action script 2.0 am coding all in one layer not within movie clips so dont give me code in that format unless nececary.I have a movie clip with instance name src_resolute and I have another movie clip that is nested inside another movie clip named endbar.What I am trying to do is when src_resolute hits endbar I want it do gotoandplay the next scene.The parrent movie clip of the nested movie clips instance name is background.If you need any more infromation let me know but basicly what I want to do is when my main character(src_resolute) makes contact with the nested movie clip(a movie clip I have drawn inside of another movie clip) I want it to jump to the next scene or more specificaly scene 4.

View 5 Replies

ActionScript 1/2 :: Hit HitTest - Reset And Replay A Move Clip?

Sep 11, 2010

Ok, so i am working on a platform game, I am new to making games, but I enjoy it! I need a little help with resetting a Move Clip if there is a hitTest! MY EXAMPLE: When the HP bar hits the bottm, my character resets. I want him to reset AND reset the the MC, or give full HP again. So, how can I take my code below and make it so that when the hitTest is true, it ALSO resets my movie clip?

[Code]...

View 5 Replies

ActionScript 2.0 :: Mouse Of One Clip Onto The Next It Fails The Hittest And Traces?

Jul 16, 2007

I am attempting to build a xml driven drop down menu where everything is taken from xml. now the problem arises with submenues. I have them being created fine, but it's the mouse out that won't work. I want to use a hittest to check if my mouse is over any of the submenues and if not just to trace something so I know it's working.

The problem is when i mouse of one clip onto the next it fails the hittest and traces. There isn't a space between the two MC's so I dunno what would be causing this. I have read sen's guide but I'm not pulling things from the library. Everything is being created at run time so I can't use the attach movie, so I am just positioning them below each other.

[code]...

View 2 Replies

IDE :: HitTest The Line Drawn In ^ With A Clip Called Enemy?

Mar 3, 2010

im making a game where when you click a line is drawn in the direction you clicked. I need to use hitTest with it, how would i go about doin that? here is the stuff.This is on the main timeline, it links to the gun. "bullet" is an empty clip

Code:

gun.onEnterFrame = function ()
{
var angle:Number = Math.atan2 (_root._ymouse - this._y, _root._xmouse - this._x);[code]....

i Need to hitTest the line drawn in ^ with a clip called enemy. How would i go about doing that?

View 3 Replies







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