P
ROTOTYPE
I'm Not Only The Prototype, I'm Also A Member.
home
▪
stats
▪
search
▪
linkback
▪
about
▪
FAQ
| user: guest,
login
,
register
Functions
:
// Screen & Client coordinates
author:
MSA
[+]
,
Submitted: 05.07.03 4a
//****************************************************************************// // Screen & Client coordinates Version 1.0 // // Original filename coordinates.as // // (c) Copyright 2001-2003 All Rights Reserved // // Sergey A. Moisevich (MSA) webdevelop@softhome.net // // Created 6/05/2003 Last Modified 6/05/2003 // //****************************************************************************// // Request Flash Player 5 or higher // //****************************************************************************// // ** This function converts global screen coordinates // to local coordinates of any movieclip _global.screenToClient = function(client, point){ while(client){ point.x -= client._x; point.y -= client._y; client = client._parent; } } // ** This function converts local coordinates of any movieclip // to global screen coordinates _global.clientToScreen = function(client, point){ while(client){ point.x += client._x; point.y += client._y; client = client._parent; } } // ** This function converts local coordinates of one movieclip // to local coordinates of other movieclip _global.clientToClient = function(client1, client2, point){ clientToScreen(client1, point); screenToClient(client2, point); } // ** Hide from for-in loop ASSetPropFlags(_global, 'screenToClient,clientToScreen,clientToClient', 1);
usage
// Include module #include "coordinates.as" // Create the movieclips clip1 = _root.createEmptyMovieClip('mc1', 1); clip1._x = 20; clip1._y = 150; clip2 = clip1.createEmptyMovieClip('mc', 1); clip2._x = -55; clip2._y = 65; clip3 = _root.createEmptyMovieClip('mc3', 3); clip3._x = 70; clip3._y = -30; clip4 = clip3.createEmptyMovieClip('mc', 1); clip4._x = -25; clip4._y = 130; // Create object with coordinates point = {x:0, y:0}; // Draw with clip2 with (clip2){ lineStyle(5, 0x0000FF, 100); moveTo(point.x, point.y); lineTo(point.x, point.y+100); lineTo(point.x+100, point.y+100); lineTo(point.x+100, point.y); lineTo(point.x, point.y); } // Convert local coordinates of clip2 to local coordinates of clip4 clientToClient(clip2, clip4, point); // Draw with clip 4 with (clip4){ lineStyle(5, 0xFF0000, 100); moveTo(point.x, point.y); lineTo(point.x+100, point.y+100); moveTo(point.x+100, point.y); lineTo(point.x, point.y+100); }
Add Comment
[+]
›opyleft 2001-2010. Layer51 is: Jaime Prado.
@