ActionScript 3.0 :: Get The X And Y Coordinates Of An Object?
Mar 28, 2011
if AS supports anything similar to hashes in perl (okay, it's been a long time since I've done any coding).If I want to get the x and y coordinates of an object I do it like this:
ActionScript Code:
thumbnails[0].getXY()[0]; // Get X
thumbnails[0].getXY()[1]; // Get Y
and I'd rather it look more like this:
ActionScript Code:
thumbnails[0].getXY(){"x"}; // Get X
thumbnails[0].getXY(){"y"}; // Get Y
We have a client server architecture where a C++ server talks to Flash clients. I'm developing the server and would like to send through tcp an xy coord to simulate a button press where the receiving flash client would find the topmost visible object at that coord and send a mouse event to it such that we could simulate play without a human present. I'm told this is incredibly difficult, but it seems to me that there must be a way to do this. Am I off the mark? Or is there a mechanism in flash to iterate through all objects regardless of parent child relationships to find a visible button at an x, y coord and signal a press event?
I have a Flash project that I would like to export the coordinates of an object from. Ideally, I would like the position of the object for each frame in the animation.
What is a good function to simply move an object to X and Y coordinates?I can find is actionscript that does movement plus other animations, like rotate and scale.I just want to let the user drag an object, but when they release it, that object moves back to certain X and Y coordiantes.
Basically there's an object in a movieclip. I want to find the location of that object in relation to the movieclip, not of the object's symbol. So when i and look at the x and y of it, it wont show 0, it will show the x and y location in the movieclip it's in.
There is a plane in my movie and it's moving (from starting point (x,y) to end point (x',y') coordinates in timeline). it's a very simple issue.And there is a popup that will be visible when user click on the plane mc.
I wrote the following code : planepp.visible = false; plane.addEventListener(MouseEvent.CLICK, planefunc);
How do I get the 2D screen coordinates of a 3D object when using Papervision 2.0 (Great White)? I've read that following properties should return the screen coords but these always return 0.
I have a string of about 5 movieclips that are tweened so that when you click left or right they slide in that direction. When you click on the movieclips themselves I want them to:
on mouse down - move to (y-5) on mouse-up - move back (y+5)
this all works fine, however after I have clicked on one of the movieclips to make it jump, when I click left or right to slide them all over again they don't slide with the rest of the clips anymore?
I need to have a textbox displaying the x coordinates of an object during its motion tween. I know how to do it for individual frames but don't know how to add an eventListener to do it over the span of the tween.
i'm trying to trace the x and y coordinates from within a sprite. i've added a rectangle to the stage:
var rect:Rectangle = new Rectangle(10, 10, 200, 200); addChild(rect); rect.x = rect.y = 100;
adding a Mouse_Move event to the rect, i can trace mouseX and mouseY to receive the coordinates of the stage while moving over the rect, but how do i get the local x and y coordinates? so if i mouse over the very top left of the rect sprite, the mouseX and mouseY return 10 as the global coordinates, but how do i make it return 0 and the local coordinates of the sprite?
i assumed localX and localY was what i was looking for, but this doesn't work:
function mouseOverTraceCoords(evt:MouseEvent):void { trace(mouseX, mouseY, evt.localX, evt.localY); }
When tracing the mouseX / mouseY or localX / localY coordinates of a display object, why does x start at 1 while y starts at 0? For example, I've drawn a simple 400 x 400 pixel sprite onto the stage with a MouseEvent.MOUSE_MOVE event listener that calls a handler function to trace the local coordinates of the mouse. The first, top-left pixel returns {x:1, y:0} and the last, bottom-right pixel returns {x:400, y:399}. Shouldn't both the x and y start and end with the same value? I'm not sure which makes more sense for a the first mouse coordinate (either 0 or 1) but it certainly doesn't make sense that they are different?
What I want to do is link the blur filter with the coordinates of an object I have in a movie.Like as the x coordinate of an object gets larger the blur amount increases as well, and decreases as the x coordinate gets lower.
i've been working on a problem for a while now, which involves targeting the closest movieClip in relation to the x y coords of the mouse, I've attached a nice little acompanying graphic.Each mc added to the stage has it's own sub-class (HotSpots) which uses Pythag to measure distance from mouse. At this stage i can determine the closest value from my Main class but can't figure out how to reference it back to the movieclip... hope this makes sense. Below are the two Classes.My Main Class which attachs the mcs, and monitors mouse movement and traces closest value.[code]
I have the coordinates of a player and another object. Both are with geographical coordinates (Latitude and longitude). I have also the direction in what the player is facing (compass). How can I calculate the angle to the other object from the player direction? e.g. I want to know if the object is to the right/left of the player and how many degrees.
how I can count the B point's coordinates (see attached image... or not as I am a new user...pf!). I know the arrow's rotation - so the angle (let's say it is -120), A's coordinates (0, 0) - A is the middle point of the arrow, and that the distance between A and B is 50 px.
I was trying to convert global coordinates to local coordinates of a UIComplenent in my flex project using below code using below code
var gp:Point = new Point(e.stageX,e.stageY); //global point var lp:Point = uic.globalToLocal(gp); //local point
uic is UIComponent in which I have subclass of Sprite for drawing something I have set the sprite's mouseEnabled and mouseChildren to false to not interrupt the mouse event. above code is within uic's mousemove event where I was tracing the gp and lp gp was giving correct value and suprisingly lp was giving negetive values. when I move the move to the top left corner of uic i expect lp to be 0,0 but it is giving the -width of of uic. I broke my head for hours and ended up finding an alternate by using offsets. Infact my original code was much simpler like this which was same issue
var lp:Point = new Point(e.localX,e.localY);
I am not sure what exactly is causing this problem. the workaround had lot of issues and it creating a mess in my rest of the algorithms.Just now I found even more interesting thing (which is actually weird). for some reason I went and create a new lp2
var lp2:Point = new Point(e.localX,e.localY);
now surprisingly it was giving correct values as expected and I went back and changed the code as
var gp:Point = new Point(e.stageX,e.stageY); //global point var lp:Point = uic.globalToLocal(gp); //local point var lp2:Point = new Point(e.localX,e.localY); var lp2:Point = uic.globalToLocal(gp);
now it is expected to have all the lp, lp2 and lp3 variables to be same but weiredly lp two is giving wrong value and lp2 and lp3 were giving correct. I am suspecting using the variable lp has something to do. I am not sure about that but above proves it so right now I am using lp2.
I was reading the 'Isometric Transformations' tutorial by Danko Kozar and I have a few questions. I understand what all the code does, but not how it does it. First of all, how does the following code work:
transforms x,y,z coordinates into Flash x coordinate xFla = function (x, y, z) { // cartesian coordinates[code].....
I understand that it converts 3d coordinates to 2d coordinates, but I don't understand how. What numbers whould be punched into x, y, and z to acquire certain desired effects?Also, what's the difference between moveTo and lineTo:
red line style(1, "0xFF0000", 100); plot(0, 0, 0); draw(200, 0, 0);
I have a task: I need to place about 100 sprites on one canvas (with prepared grid on it). I need to place them as invisible (circles) stones, on the board, and make visible only on mouseover. The problem I come across is following, I can't place those objects accurately into the nodes on the grid.
Im making a little app in flash using papervision I want to make a regular movieClip show up in the same place as a papervision object. The coordinates seem like perspective is affecting the number displayed.
this is probably something thats solved verry easy, but I tried all kinds of google terms etc and I can't find a solution.On my stage, I have a symbol, in this symbol (button) the following code:
I have a movieclip inside another movieclip.[code]...
I can get mc_inside._x and mc_inside._y properties relative to the container movieclip, but how can I get the mc_inside._x and mc_inside._y relative to the _root (the stage)?
I'm having a helluva time trying to figure out why I can't load a display list object, (multiple times) at different coordinates specified in my xml file.tremendous as I am not the most accomplished with AS3. Here's the code I'm working with...