Register to earn points!
Login
Register
3D
ActionScript
Applications
Banners
Bitmap
Buttons
Effects
Fractals
Galleries
Games
Intros
Logos
Menus
Other
Particles
Physics
Players
Preloaders
Text
Homepage
|
News
|
Subscribe
|
Member list
|
Links
|
Submit File
Pythagorean Distance Between Two Points - Free Flash Other - Flash Source Codes - By
dario111cro
Overall rating:
Your rating:
Login to rate
Download
Login
File info
673 plays
Title:
Pythagorean Distance Between Two Points - Free Flash Other - Flash Source Codes
Description:
Learn how to calculate distance between two points.
ActionScript:
AS2
Comments
Log-in to add a comment
smily
(90)
AS3:
var ll:Sprite=new Sprite();
ll.graphics.lineStyle(2, 0x0, 100);
ll.graphics.moveTo(p1.x,p1.y);
ll.graphics.lineTo(p2.x,p2.y);
ll.graphics.moveTo(p2.x,p2.y);
ll.graphics.lineTo(p1.x,p2.y);
ll.graphics.moveTo(p1.x,p2.y);
ll.graphics.lineTo(p1.x,p1.y);
addChild(ll);
p1.addEventListener(MouseEvent.MOUSE_DOWN,sta_Move);
p1.addEventListener(MouseEvent.MOUSE_UP,sta_stop);
function sta_Move(e:MouseEvent):void
{
p1.addEventListener(MouseEvent.MOUSE_MOVE,sta_line);
p1.startDrag();
}
function sta_stop(e:MouseEvent):void
{
p1.stopDrag();
}
function sta_line(e:MouseEvent):void
{
ll.graphics.clear();
ll.graphics.lineStyle(2, 0x0, 100);
ll.graphics.moveTo(p1.x,p1.y);
ll.graphics.lineTo(p2.x,p2.y);
ll.graphics.moveTo(p2.x,p2.y);
ll.graphics.lineTo(p1.x,p2.y);
ll.graphics.moveTo(p1.x,p2.y);
ll.graphics.lineTo(p1.x,p1.y);
}
TogaGames
(808)
Cool
Wolfos
(771)
okay, so I went researching and this code is way too complicated.
I did it with this code:
a = this.A._y - this.B._y;
b = this.A._x - this.B._x;
csquare = Math.pow(a,2) Math.pow(b,2);
c = Math.sqrt(csquare);
output = c;
Wolfos
(771)
maybe a better explanation:
what you're doing here is:
-calculating the y distance between A and B
-calculating the x distance between A and B
-then a^2 b^2 = c^2
-so c is the root of the answer (√a^2 b^2)
More files
Sniper Effect 2
This is a cleaned up version of the sniper effect which also includes a decent menu system inside and credits code.
spawning particles 2
same as 1, but spawning at different sizes and with another colour.
Aires Photo Gallery V2
After the first version to download more than 7600 ... The second version comes with a code, but simple and clean, has some features not ...
Random mouse dots
This creates some random circle, of random colors when you move your mouse
Dynamic Gallery
xml dynamic gallery with slide show.
var ll:Sprite=new Sprite();
ll.graphics.lineStyle(2, 0x0, 100);
ll.graphics.moveTo(p1.x,p1.y);
ll.graphics.lineTo(p2.x,p2.y);
ll.graphics.moveTo(p2.x,p2.y);
ll.graphics.lineTo(p1.x,p2.y);
ll.graphics.moveTo(p1.x,p2.y);
ll.graphics.lineTo(p1.x,p1.y);
addChild(ll);
p1.addEventListener(MouseEvent.MOUSE_DOWN,sta_Move);
p1.addEventListener(MouseEvent.MOUSE_UP,sta_stop);
function sta_Move(e:MouseEvent):void
{
p1.addEventListener(MouseEvent.MOUSE_MOVE,sta_line);
p1.startDrag();
}
function sta_stop(e:MouseEvent):void
{
p1.stopDrag();
}
function sta_line(e:MouseEvent):void
{
ll.graphics.clear();
ll.graphics.lineStyle(2, 0x0, 100);
ll.graphics.moveTo(p1.x,p1.y);
ll.graphics.lineTo(p2.x,p2.y);
ll.graphics.moveTo(p2.x,p2.y);
ll.graphics.lineTo(p1.x,p2.y);
ll.graphics.moveTo(p1.x,p2.y);
ll.graphics.lineTo(p1.x,p1.y);
}
I did it with this code:
a = this.A._y - this.B._y;
b = this.A._x - this.B._x;
csquare = Math.pow(a,2) Math.pow(b,2);
c = Math.sqrt(csquare);
output = c;
what you're doing here is:
-calculating the y distance between A and B
-calculating the x distance between A and B
-then a^2 b^2 = c^2
-so c is the root of the answer (√a^2 b^2)