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.
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.
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);
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;
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?
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?
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.
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?
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.
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?
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?
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.
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.
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.
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.
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]...
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?
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.
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);
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?
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]...
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.