ActionScript 2.0 :: Find Distance Of Mouse To Center Of MC
Sep 17, 2007
I created a movie where I have a circle in the middle and a line drawing from the center out when the mouse moves. I want to calculate the distance from the mouse position to the middle of the circle. What I am going to do is have a sound playing from the center of the ball..The closer you get the louder the sound gets and the further away from the middle the quieter it gets. You can download my fla to see what I have so far.
View 1 Replies
Similar Posts:
Jun 17, 2005
I am working on the project where everything is based on the distance from the center of the stage. First I made this fla where flash outputs the x and y distance from the center. First problem is that I want to output distance only in positive numbers.
View 1 Replies
Jan 26, 2011
I have been looking to scale an object up if it's less than 70-px from the center of the object. I started to use the below and at least the distance was working but when combined with the conditional it all falls apart as the object mousePoint changes rapidly.This works fine when tracing:
ActionScript Code:
var mousePoint:Point = new Point(this.mouseX,this.mouseY);
var mcPoint:Point = new Point(0,0);
[code]....
View 6 Replies
May 3, 2010
I just copied the code from my new bff Lee at gotoandlearn for carousel rotation (but instead of changing direction based on the mouse's distance from center, I'd like it to change based on distance from a center line at a 45 degree angle.
Code:
var numOfBalls:Number = 365;
var radiusX:Number = 360;
[code]....
View 2 Replies
Sep 20, 2011
I am rotating an object with TweenLite, however instead of a set duration I want the duration to be based upon the distance of rotation where 180 degrees = 3 seconds 90 = 1.5 and so on. Here is my attempt to find the distance of rotation:
var time:Number = Math.abs(Math.atan2(Math.sin(angle-wheelObj.rotation),Math.cos(angle-wheelObj.rotation));
TweenLite.to(wheelObj, time, {shortRotation:{rotation:angle}, ease:Expo.easeOut, onComplete:rotateWheel, onCompleteParams:[target]});
TweenLite.to(carObj, time, {shortRotation:{rotation:angle}, ease:Expo.easeOut});
This just isn't working, time is sometimes huge when the rotation is small and sometimes tiny when it is big, so does anyone know a better way to do this?
View 3 Replies
Sep 22, 2011
This code calculates the distance between 2 points by using distance formula, Math.sqrt ( (x1 - x2)^2 + (y1 - y2) ^2). My first point has mmx and mmy coordination and second one has ox and oy coordination. My question is simple, is there any FASTER way for calculate this?
[Code]...
View 3 Replies
Feb 14, 2011
How could I find the distance between a given point and a drawn line? I was thinking about using the point-slope formula to draw a perpendicular line between the point and the line and measuring it as the distance, but I'm not quite sure how to do this in as3.
View 0 Replies
Jun 28, 2011
How does Flash use Math.sqrt to get the distance between 2 movieclips? In the example the only givens are 2 points along a triangle:
function getDistance(x1:Number,y1:Number,x2:Number,y2:Numbe r):Number {
var dx:Number=x1-x2;
var dy:Number=y1-y2;
return Math.sqrt(dx*dx+dy*dy);
}
dx is the difference between the x coordinates of 2 points/2 mc's
dy is the difference between the y coordinates of the same 2 points
the Math.sqrt is the Pythagorean theorum
If the Pythagorean theorum is a^2+b^2=c^2 for the sides of a triangle how do 2 points achieve the same result if the lengths of the sides aren't given?
View 1 Replies
Feb 23, 2012
How can i use Geo location to find the distance traveled? Im trying to develop this iphone app but i cant figure it out
View 2 Replies
Aug 4, 2010
Is there a way to find the radial distance using the zipcode? My task is to search the all the users residing with in a specified distance. I know the zipcodes of the users. Eg, users between 25 miles from the current location. I have other search categories, for which i am using mysql queries. I am unable to figure anything out for the distance issue.
My backend is in php
and frontend in Flex.
The best option for me would be something like that of www.zip-codes.com/zip-code-radius-finder.asp. ie, if I should be able to get all the zip-codes available in the specified radial distance. So i can compare this zip-codes to the users zip-codes in my database. And select the ones with a match.
View 5 Replies
May 19, 2003
So, right now when I want to find the distance between two points, I go: dist = Math.sqrt((this_x-that_x)*(this_x-that_x)+(this_y-that_y)*(this_y-that_y)) BLECH! I don't want to do that every time. So I want to make a nice little function that I can apply to an object. Problem is, I don't know how to do this. Is it possible to end up with something as easy as: Math.dist(thisclipname, thatclipname)? How do you guys set up functions that do bulky math and return nice clean numbers?
View 4 Replies
Mar 28, 2011
Not sure this exist, but worth asking you all: is there a built in method to compute the distance between the current mouse position and a given component? If not, is there a simple way to build a function like this that works for components with generic shapes?
View 2 Replies
Aug 12, 2009
how to detect the distance of the mouse movement in a certain time. I d like to be able to calculate the distance the mouse was moved from one point to another in certain time (one second) and compare these values.
View 2 Replies
Aug 12, 2009
I am wondering if anyone can share with a good example on how to detect the distance of the mouse movement in a certain time. I'd like to be able to calculate the distance the mouse was moved from one point to another in certain time (one second) and compare these values.
View 2 Replies
Aug 12, 2009
how to detect the distance of the mouse movement in a certain time. Id like to be able to calculate the distance the mouse was moved from one point to another in certain time (one second) and compare these values.
View 0 Replies
Aug 12, 2009
How to detect the distance of the mouse movement in a certain time. I'd like to be able to calculate the distance the mouse was moved from one point to another in certain time (one second) and compare these values.
View 3 Replies
Dec 4, 2009
What I am trying to do with AS3 in Flash cs4 is calculate the cursor's distance to given point (let say 400,300) and use that distance to constantly (20 fps) change my curtain's alpha value. (which is basically a box turned into a movie clip) [code]...
View 5 Replies
Aug 26, 2010
i am trying to find center point of my pie.
var myTween:Tween = new Tween(piechart,"............", Strong.easeOut,1200, 510, 1, true);
i want to animate from the center and it has a xml driven data file.
View 2 Replies
Sep 26, 2003
How do you find the center of a movie that has has been loaded by loadMovie();
This is the method I was using, but now that it is in a .swf that has been loaded it's stoped working
[AS]
xcenter = box._x + ( box._width /2);
[/AS]
View 4 Replies
Jun 9, 2011
How to keep a MC a certain distance from the mouse cursor regardless of angle?
View 10 Replies
Dec 22, 2011
How can i calculate the mouseX distance from an MC?
i'm using this:
Code:
enterFrame event {
var d1:Number = pi(mouseX,dist0.x);
var d2:Number = pi(mouseX,dist4.x);
[Code]....
View 3 Replies
Aug 31, 2010
I don't seem to be able to find the right wording to find my answer anywhere.How do I determine where an MC's center is relative to its edges?I'm developing a tool that a variety of noobs (as if I'm not still a noob) will be using, and I don't trust them to keep art with 0,0 being the top left corner.How do I figure out that the left edge is now at -111px, and the top at -52, and the right at 12, and the bottom at 334?
View 3 Replies
Sep 1, 2010
I have an image and I need to be able to click on 2 different points within the image and be able to have it tell me how far apart these 2 points are.
View 7 Replies
Feb 23, 2011
I'm trying to figure out how to make an object move vertically or horizontally a set distance once the object has been mouse clicked and then stop. Sounds relatively simple, but I'm pretty clueless at it.
View 2 Replies
Sep 5, 2011
im building my site now and i want to have background of hexagons that get visible only when the mouse is at certain distance of them, so i found out that i have to use as3, ive read some tutorials and other post and i tried the following code that i found online:
stage.addEventListener(Event.ENTER_FRAME, showDistance);
function showDistance(e:Event):void{
var distance:Number = (circle.x, mouseX, circle.y, mouseY);
[code].....
View 9 Replies
Jul 19, 2009
I have a AS2 movie clip that has a drag navigation. The movie clip is bigger then the visible area. How can I find the center xy of the current visible area when I stop the drag?
View 2 Replies
Dec 6, 2009
How to find out different circle's center point of a bitmap?
just like photo above, how can i locate the 2 center points of circles?
i only know using .getColorBoundsRect to get a point, but this only apply to one circle, in fact i wanna get different points according to the bitmap.
View 1 Replies
Dec 1, 2010
I'm trying to add some zooming functionality. The problem is that when you zoom in and out, it scales the MC up and down from where the registration point is. This means That when I'm far from the position of the registration point instead of zooming the in straight it also makes it appear as if you are travelling towards the registration point.
To offset this effect I want to calculate the amount of pixels I need to offset the Map by so that it appears as if you are zooming in directly.
So just as a test I've put a little ball inside the map(called "center") which I'm trying to keep in the center of the map.[code]...
View 1 Replies
Oct 16, 2010
I am posting my code that attaches the movieclips on stage
[Code]...
i was hoping that when the newMc expands, all other mc would keep the same distance between each other as at initialisation. I not able to figure how to do it. maybe even an earlier post or llink where similar query was explained.
View 1 Replies
Apr 28, 2011
In AS3 I am trying to get the distance between 2 3D objects by using distance method.
if(Vector3D.distance(model.position,model2.position) < 100)
{
// do something
[Code]....
>>You can use it directly as a method of the Vector3D class to get the Euclidean distance between two three-dimensional points.
Which point does this method pick? Is it the closest point to the other object ?
I am just thinking of how much time this would take in testing objects with large poly count.
View 1 Replies