ActionScript 2.0 :: AS2 Hittest On Rotating Shapes /w Mouse

Mar 27, 2011

I've googled for hours and found nothing. I did find a lot but none involved hittesting with a mouse cursor. I'm trying to make a simple maze game, so far it works, I die when I hit squares and rectangles, but I die incorrectly when hitting a rotating rectangle.Because it rotates, the bounding box is larger and a normal hittest sees bounding boxes, meaning it won't work.Make it so that my mouse can go near the rotating rectangle without dying until I actually touch the actual rectangle instead of the bounding box.

View 2 Replies


Similar Posts:


ActionScript 2.0 :: GRRR Hittest Odd Shapes?

Oct 7, 2006

okay ive looked at tutorials on hittest and how to stop a movie clip from moving when it hits a wall and stuff but none of it can tell me how to make a movie clip stop moving when it hits any side of an odd shaped movie clip. for example, i have the moving clip, guy, with this code:

[Code]...

and i have another clip, table, which is an L shaped movie clip and i want the guy to not move through any side of the table.. sounds simple enough. but nowhere i have looked can explain how to do this.

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 :: Controlling Two Different Shapes With Mouse Events

Feb 14, 2011

I'm attempting to control 2 different shapes (a red rectangle and a blue rectangle) with the same sequence of mouse events (down, move, up), but only one shape at a time must move. The shapes are locked horizontally along the x-axis. The red rectangle, which starts out on the left side of the stage, has a right-registration while the the blue rectangle on the right side of the stage has a left-registration.

The rectangle that moves during the MOUSE_MOVE events is the shape that is closest to the *MOUSE_MOVE* event's stageX property. The closest rectangle is determined by averaging the x property of each rectangle (averageX)in relation to the MOUSE_MOVE stageX property. Therefore, if stageX is less than averageX, the shape on the left should move. Greater than averageX, the shape on the right.

The problem occurs when control changes rectangles during subsequent MOUSE_MOVE events, before MOUSE_UP. Variables that are set during MOUSE_DOWN are appropriate for the rectangle that is moved first, but things become dicey when the other rectangle is to be moved instead. Basically, the rectangle whose x property is closest to MOUSE_MOVE event's stageX property should move along either left or right with the mouse event, one at a time.

For simplicity with the following code example, a MOUSE_DOWN event could always occur somewhere between the two rectangles.
package{
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.MouseEvent;
[Code] .....

View 1 Replies

ActionScript 3.0 :: Masking Irregular Shapes For Mouse Events

Jan 10, 2009

I have a MovieClip that contains a GIF bitmap that is a non-rectangular object (e.g. a star). All the pixels outside of the star are Transparent. Is there a way I can somehow programmatically limit Mouse events to fire only when the mouse cursor is within the star region (but not in the rest of the transparent rectangular area)?

View 6 Replies

ActionScript 2.0 :: Draw Shapes With Mouse Inside A Scrollpane

Jun 25, 2008

I'm trying to create a draw program in AS2 where I can draw shapes with my mouse inside a Scrollpane. Furthermore, I need to be able to drag and drop these objects within the Scrollpane. Currently, I'm doing the following:

1) I created an empty movie clip called main and I'm attaching it inside the Scrollpane called scroll

2) I draw the objects inside another empty movie clip called p0, p1, p2, etc. which I'm attaching inside main. When I drag the objects around, they can be dragged outside the boundaries of the Scrollpane. How can I prevent that from happening?

View 3 Replies

Flex :: Manage Mouse Clicks On Irregular Button Shapes?

Mar 1, 2010

In Flex, I am trying to design 3 buttons similar to the image uploaded at [URL]

The mouse over/click on image should work only on red colored area of the button.
How can I manage the Mouse clicks or Irregular Button shapes in Flex?

View 3 Replies

ActionScript 3.0 :: Import Shapes Directly From The Library As Shapes And Not As Sprites / MovieClips?

Feb 17, 2009

I have a question about shapes (i mean the flash.display.Shape class). Is it possible to import Shapes directly from the library as Shapes and not as Sprites/MovieClips? Shapes are supposed to be faster than MovieClips/Sprites, right? So why is it only possible to import MCs/Sprites from the library? I understand that generally shapes could be created solely by actionscript, but in my case the shape comprises of many points and is curved - so it's quite infeasible.

Is there maybe some sort of plugin to generate code that would draw the desired shape from a drawn shape in CS4? And a last one: Are there any benchmarks out there for performance comparison between sprites/mcs/shapes? How much performance do i loose by using a sprite instead of a shape?

View 2 Replies

ActionScript 2.0 :: How To Avoid Mouse HitTest

Nov 24, 2003

I am creating a menu with nested MCs, of course, and the parent MC is using a RollOver action. The problem with that is: all other nested MC's RollOver action are not detected. I know you can use a mouse hitTest as a work-around i.e.:
Code:
onEnterFrame = function(){
if(this.hitTest(_xmouse,_ymouse,true)){
//do whatever
}}
But I'd like to avoid using that if possible.

View 7 Replies

ActionScript 2.0 :: How To Avoid A Mouse HitTest()

Nov 24, 2003

im creating a menu with nested MCs, of course, and the parent MC is using a RollOver action. The problem with that is: all other nested MC's RollOver action are not detected. I know you can use a mouse hitTest as a work-around ie:

Code:
onEnterFrame = function(){
if(this.hitTest(_xmouse,_ymouse,true)){
//do whatever
}
}

but i'd like to avoid using that if possible.

View 7 Replies

ActionScript 2.0 :: [CS3] Rotating Using Mouse Coordinates

Mar 12, 2008

I'm trying to create a simple site that when you move the mouse to the right of the screen a movie clip rotates one way abt 45 degrees and moves the other way when the mouse moves to the left.

I'm trying to get the effect of a horizon line rotating to the mouses movement around the screen.

View 10 Replies

ActionScript 3.0 :: Rotating A Movieclip Using The Mouse?

Mar 30, 2009

I have been trying to convert this effect into AS3 but have been having majour issues : rotate clip

I have an object (class) with a handle, when dragged I would like the clip to rotate with the mouse (much like rotating an object in photoshop). I have put my code into an ENTER_FRAME event, and have been using a matrix object to do my rotation (is there an easier way?)

Code:
private function rotateClip(e:Event)
{
myMatrix.rotate((Math.floor(180*Math.atan2(mouseX,mouseY)/Math.PI)+90));

[Code].....

was my attempt at converting the code from the example link. I've also tried various other methods using trig to no avail.

View 1 Replies

Object Following Mouse, Rotating Left And Right?

Oct 11, 2010

I am working in AS2 and I have a flash project that is almost complete but I would like 1 thing modified.I have a fish image following my mouse.

(script below)
onClipEvent (enterFrame) {
_root.yChange = Math.round(_root._ymouse-this._y);[code]...........

The problem is that I would like the fish image to "turn" and face the direction of the mouse. Currently, as is, the fish follows the mouse fine when the mouse is moving to the right, but when it goes to the left the fish swims backwards rather than turns and swims the correct way following the mouse to the left.How would I modify the script to get the fish to turn and always swim forward when going left and right?

View 3 Replies

ActionScript 1/2 :: Rotating Through Frames Via The Mouse?

Sep 21, 2009

I am working on an animation that I need to rotate in flash, via the mouse?
 
Is there a way to cycle through the frames left and right via the movement of the mouse?

View 8 Replies

Actionscript 3.0 :: Rotating To The Mouse Position?

Apr 8, 2009

Im trying to follow an example and get a simple arrow sprite to rotate to the mouse position. This example comes out of the book 'Foundation Actionscript 3.0 Making things move' however when I build the following .as files, open a new as3.0 document, assign the document class to RotateToMouse, run the movie the swf's stage is blank and lacking the arrow sprite im telling it to create.

Code:
Code: Select allpackage
{

[code]....

View 1 Replies

ActionScript 3.0 :: Rotating Circle By Mouse?

Jan 31, 2010

I have been working on this and thinking about it for days but I just can't seem to get it right. I want to have a circle that I can "pick up" with the mouse and then rotate (with the rotation point in the center). Currently I have done this with the following code:


PHP Code:

 var radians = Math.atan2(mouseY-circle.y, mouseX-circle.x); var degrees = Math.round((radians*180/Math.PI));  circle.rotation = degrees + 90; 

I have added a mouse listener for movement to the circle mc and then checked if a button was down. On button down this code would be executed on enter frame. This code works but the main problem is that I want to be able to "pick the circle up" at any angle and rotate it. If I pick it up with this code the circle automatically rotates to 90 degrees.

View 14 Replies

ActionScript 2.0 :: HitTest Of Moving Object With Mouse?

Dec 17, 2009

My first post in Actionscript.org. but I'm a long time visitor / fan. I'm moving a object with mouse but using some easing values. means it will follow the mouse slower.

Here is the file.[URL].. How can i check hitTest in this situation. even if i do it normally...the object is passing the collision object simply before stopping..because its being moved with mouse..

[Code]...

View 0 Replies

ActionScript 3.0 :: Using HitTest With BitmapData And The Mouse: Hover Gfx?

Jul 31, 2011

Having used copyPixels to display an image, I'm trying to copy another in it's place when the mouse is hovering.The only way I can copy the new image over the old is by setting the If statement to == false. I know there's something wrong with testing the bitmapData of the loaded .png because the hitTest would apply to anything copied from that tile sheet... but how to designate just the copied area?

ActionScript Code:
package 
{

[code]......

View 4 Replies

ActionScript 3.0 :: Rotating Circle From Center With Mouse/

Jan 31, 2010

I have been working on this and thinking about it for days but I just can't seem to get it right. I want to have a circle that I can "pick up" with the mouse and then rotate (with the rotation point in the center). Currently I have done this with the following code:

PHP Code:

var radians = Math.atan2(mouseY-circle.y, mouseX-circle.x);
var degrees = Math.round((radians*180/Math.PI));
circle.rotation = degrees + 90;

I have added a mouse listener for movement to the circle mc and then checked if a button was down. On button down this code would be executed on enter frame. This code works but the main problem is that I want to be able to "pick the circle up" at any angle and rotate it. If I pick it up with this code the circle automatically rotates to 90 degrees.

View 1 Replies

ActionScript 2.0 :: Whenever Move Mouse Over It , It Should Stop Rotating?

Jan 28, 2009

am new action script just started to learnstarted with 2.0 i had small scenario imagine any shape which is in rotating motion through motion tweennow what i what is through AS whenever i move mouse over it , it should stop rotating

View 1 Replies

ActionScript 3.0 :: Smoothly Rotating Object Towards Mouse

Oct 13, 2010

I am trying to make an object smoothly rotate towards the mouse.
ActionScript Code:
var rot:Number = 0;
var smoothing:int = 5;
stage.addEventListener("enterFrame", step);
function step(e:Event):void {
// point_direction is a function I have created that finds the angle between 2 points. I know this functions works as it is supposed to
rot = point_direction(obj.x, obj.y, mouseX, mouseY);
obj.rotation += (rot - obj.rotation) / smoothing;
}
This code works, except when I pass the mouse over the center of the object on the left side it seems to spin the long way around. So if I move the mouse down the center of the object on it's left side, it will spin a long way counter-clockwise to reach the mouse instead of the tiny length if it had spun clockwise.

View 3 Replies

ActionScript 3.0 :: Rotating MovieClip To Point At Mouse

Jul 4, 2007

I am trying to make a line point to wherever the cursor is when I stumbled upon the Math.atan2(); function. It appeared that i would put
line.rotation = Math.atan2(1,1);
to get 45 degrees or pi/4, but I was wrong. It barely moved the movieclip at all. So what I'm trying to do is to get this movie clip to rotate along with the mouse so the line is always pointing at the cursor. Also, how would you get movieclip to move along the line created by the line of these two points?

View 9 Replies

ActionScript 2.0 :: Rotating MovieClip Towards Mouse Position

Feb 12, 2005

Any way to rotate a movieclip to face the mouse location?

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

ActionScript 3.0 :: Hittest True After Mouse Exits Stage?

Oct 20, 2010

i have a hit test point on display object, and if i exit stage over that display object, and then run hit test point it will return true, although my mouse is not over stage area any more, like it remembers the last mousex, mousey coordinates where mouse was and reports that.how do i deal with it?i know i can detect mouse_leave on stage and mouse_out on displayobject.

View 3 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 :: Rotating Turret That Will Follow The Mouse 360 Degrees?

Mar 18, 2009

i am terrible at explaning things but i'm going to try my best.for example. I have a rotating turret that will follow the mouse 360 degrees.so i wonder if it is possible to go inside the turret ("mc") and stop at frame (2);when the turret reaches 170 degrees.

View 2 Replies

ActionScript 2.0 :: Stop The Object From Rotating When Roll The Mouse Over?

Jan 4, 2006

i have my fla here.

i want to stop the object from rotating when i roll the mouse over.

View 4 Replies

ActionScript 2.0 :: Write A Class That Will Hittest For Mouse Touching A Menu?

Feb 7, 2009

I am trying to write a class that will hittest for my mouse touching a menu. The class is attached to the linkage of the actual menu MC. I can't seem to get a hit, I think, what am I doing wrong?

Code:
import mx.events.EventDispatcher;
import mx.utils.Delegate;

[code]......

View 2 Replies

ActionScript 3.0 :: HitTest For Mouse Position Over A Bitmap Inside A MovieClip?

Dec 1, 2009

This seems like it should be simple, but... I've been trying to figure out how to do the following, and I can't seem to make it work. It all works except for the hit test part. I have a working drag and drop application. I need something different to happen when the user drops an object while the mouse x,y is, or is not over a certain (very irregularly shaped) bitmap inside a movieClip. how to do this? I have found some complicated ways to hit test between 2 bitmaps, but not 1 bitmap and mouse x,y.

View 3 Replies







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