Actionscript 3 :: Convert Global Coordinates To Local Coordinates Of A UIComplenent In Flex Project?
Dec 19, 2011
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.
View 1 Replies
Similar Posts:
Feb 4, 2010
I made a cube with as3. I wanted it to rotate in the Y Axis according to the horizontal mouse movement. It works nice when this is all I want. But if I try to also make it rotate on the X axis with the vertical mouse movement, things get screwy.
This happens because the transformations are added in the global coordinates, not the local ones. So, for Example, if I wanted the cube to rotate 30 degrees along its Y axis, I have to find a way to translate that into the global coordinates, and then apply that to the matrix3D of each face. I need a local to global translator.
[Code]...
View 1 Replies
Dec 15, 2011
I have a texInput component,which is placed inside containers like following
<s:BorderContainer ...>
<mx:VBox ...>
<mx:HBox ...>
[code].....
View 1 Replies
Oct 19, 2010
I am trying to determine the global coordinates of the visible rectangle that is currently rendered on the stage.
Specifically, if a canvas has an explicit height and width and is a child of a panel that has a scrollbar, the scrollbar can "hide" a part of the canvas. ContentToGlobal(x,y) provides the global position of the content at the time, but content coordinates can scroll off the boundaries of the parent panel and continue to give x,y coordinates that are not visible.
Is there a way to determine the viewable rectangle that is not hidden by anything?
View 2 Replies
Feb 20, 2012
I have a texInput component,which is placed inside containers like following
<s:BorderContainer ...>
<mx:VBox ...>
<mx:HBox ...>
<mx:TextInput ...>
[code]....
Now after initialization i want to get the location of my textInput with respect to Application.I tried with with localToGlobal(PointofLocalCoridnate), then it is not giving the correct location of textInput.
View 8 Replies
May 21, 2007
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);
View 4 Replies
May 3, 2010
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.
View 2 Replies
Apr 24, 2009
I have a MovieClip ("mc3" that moves dynamically) inside of a MovieClip ("mc2" that moves dynamically) that is on the stage ("stage" that is static). I need to find the value of mc3's x in relation to the stage? I need to make it into a variable. I am trying to do the math, can't figure it out. Also tried localToGlobal and failed.
View 5 Replies
Oct 27, 2010
I have a small problem with usage localToGlobal and than back to local. I can get global coordinate of my nested mc in question alright. Than i check if this coordinate + value of my mc.width is more than my stage width. I get to this part with no problem. Than if value is bigger (so mc is not on the stage i mean if part is off the stage i change value so it is stage width - mc.width). So i get value in global coordinates that i need. But how do i apply this to my nested clip is my question? For reference here is my code:
[Code]...
View 3 Replies
Aug 18, 2010
I have a symbol originally created at [-100,-100] coordinate (left top corner). Now I put an instance of this symbol on a stage at [0,0] stage coordinates (by dragging it with a mouse in IDE). Having this instance can I still determine original [-100,-100] position from actionscript somehow? ([code]...
View 4 Replies
Sep 29, 2011
Is it possible to change the coordinates of a project so that is it more like a graph?
Eg. The center of the page is 0,0 and the bottom is -200 and the top is 200
View 4 Replies
May 27, 2010
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);
}
View 3 Replies
Nov 24, 2009
my mission is to select an item in a DataGrid instance with nothing but the coordinates on screen.
We are implementing right-click functionality in our Flash application, with the goal of being able to right-click a DG row, which would select that row plus show a popup window containing some context commands.
I have managed to get the right click event into my Flex app with the help of this site.
Further progress so far has been to obtain the DataGrid instance via
var objects : Array = this.getObjectsUnderPoint(new Point(this.mouseX, this.mouseY));
and then to investige each of the array's items, for one of those 'parent.parentList' refers to the DataGrid instance.
I couldn't find any point-to-item converter function or anything.
PS: Using the standard Flash ContextMenu is, unfortunately, not an option.
View 3 Replies
Nov 24, 2009
I'd like to have an overlay that draws lines between selected items in different Flex 4 List controls.
The problem is I can't figure out how to access the x, y coordinates of the list's item renderers.
View 2 Replies
Mar 11, 2010
when I use startDrag() and stopDrag() to drag an object why doesn't it effect the x,y coordinates of the object? you can run this example and see for yourself (move the circle and look at the trace messages):
[Code]....
View 3 Replies
Jun 2, 2010
The orange square is the currently selected selected sprite. The sprites are all draws from coordinates that i receive from XML. var sprObject:Sprite = new Sprite();
[Code]...
What I want to do is the following. If I'm currently on the orange square and I use my keyboard direction buttons (up/down/left/right). I want to deselect the current sprite and select the next sprite in the appropriate direction. The problem I'm having is that I cannot get the x and y coordinates of the drawn sprites. If I look in the array, the x and y coordinates of the sprites are all 0. If I can retrieve that I can write an algorithm to determine the next sprite to select.
View 1 Replies
Mar 17, 2011
I am working on panoramic scene . And I want to move a plane with cursor. When I move mouse, plane must be mouse coordinates. And I want to take plane 3D coordinates (x,y,z) expecially z-coordinate. I try below code. But it doesnt work correctly. Mouse and plane are not be same coordinates on screen. How I can do?
public class RayTracer
{
public static function getIntersection(viewport:Viewport3D, camera:CameraObject3D, normal:Array):Number3D
[Code]....
View 3 Replies
Mar 1, 2012
We have an image editor in Flex to add text and other changes. Once all the changes are complete, we need to save this to the server.We are using php to save the images by accepting coordinates from flex about what all edits are made for that image. Using this we are editing that image using imagick function in PHP. But the problem is output is different from what we see in flex. The issue is mainly with text alignment in flex editor and in the output we get after editing in php.Is there any other way to do this without making the user to wait for a long time to save the images? Is it possible to get the correct coordinates of text from that flex editor. Our issue is flex is passing the x,y of the container of that text editor. For this reason, test is misaligned in the output.
View 1 Replies
Nov 30, 2009
I know that the question may seem very easy. I am trying to display an image on canvas.I need to do it in AS, and also I need to locate image in specific coordinates.
View 2 Replies
Feb 24, 2011
Within my component, I'm drawing some rectangles as below:
[Code]...
I need to display a custom tooltip for each rectange when the mouse cursor is hovering over it.
How can I do this? I'm using the MouseMove event to track when the cursor moves over these coordinates (that part is working), but when I change the tooltip text it's not refreshing
private function this_MOUSE_MOVE(event:MouseEvent):void
[code]...
EDIT: The problem seems to be with the following line:
ToolTipManager.destroyToolTip(_myToolTip);
If I comment out the preceding line, it will display the new tooltip, but it will keep creating new ones and the old ones never get removed. But if I add that line, it doesn't add any tooltips! Is the code not being executed sequentially, i.e., is the code to remove the tooltip somehow getting executed after the code to add the tooltip?
View 1 Replies
Mar 4, 2011
I googled for almost a day to find the answer to my question: [URL]. This almost works (and is a great solution), but the solution doesn't work when I do:
1). Copy and paste multiple-line texts.
2). Write long and scroll the texts.
I also found another working example at: [URL]. (The autocomplete prompt appears when you press ctrl+space right at the caret's position). But an email from its author says he uses monotype fonts to calculate individual character's location. Is there a way to get multi-line input from a textfield?
View 1 Replies
Jun 17, 2011
I have a list with custom item renderers. What I would like is when one of the list items is selected to position another control OUTSIDE the list to the same vertical position as the selected item.
View 2 Replies
Jul 21, 2010
How do I get the size of the content area of Container objects? One non generic solution is checking for styles I suppose but I am looking for some code that works generic for all standard flex Container objects. The controls are Flex 3
View 1 Replies
Apr 12, 2011
In my Flex project, can I add markers by its address instead of this:var myGeographicCoordinates:LatLng = new LatLng(myLatitude, myLongitude);for example add marker by "Paris, France"
View 2 Replies
Jun 29, 2011
I have a flex mobile project and I want to convert it into web-based project. What is the best way to do it.
View 1 Replies
Sep 4, 2011
I've been searching extensively for a way of converting from ordanance survey coords to valid esri coordinates. I've found quite a few pages that convert to lat long (if a little off) but nothing to convert to esri (which I believe is utm.)This is for use in python or JavaScript / actionscript etc - I'm not too worried about syntax more an understanding of the maths involved.
View 2 Replies
Oct 14, 2009
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.
[Code]...
View 2 Replies
Jan 23, 2012
I am running Flex mobile project and I would like my mobile app to be able to load and display pdf files that are saved locally. I do not want to go out to the web to access these pdf files.
I cant figure out how to make this code work for a locally saved file.
Error MSG: "Error #2044: Unhandled ErrorEvent:. text=Load error."
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
overlayControls="true" title="PDF Display"
[Code]...
View 2 Replies
Jan 19, 2012
I trying to play a flv file in a flex mobile (flex 4.6) The files will all be locally stored and on the device. Would it be better to use the video even if it is not supported or can i use a movieClip? I am going to try and fade out a picture and then play the video with out any user controls and then fade back to the picture. The this will all be on a tablet. I am using Flash Builder 4.6.
View 1 Replies
Jan 9, 2012
my Flex project has grown to over 1 Mb in size in release mode and now I am trying to cut it up into modules.
One of my SWC libraries is fairly large and I want to use it in multiple modules, so I think I can turn it into a RSL? how can I go about turning the SWC library into a RSL? I am building with Flash Builder (Flex).
View 1 Replies