Flash :: Determine Absolute Object Coordinates?
Oct 27, 2009What is the simplest way to determine absolute object coordinates in AS3?
View 1 RepliesWhat is the simplest way to determine absolute object coordinates in AS3?
View 1 RepliesIs there a method to determine the stage coordinates of a movie clip?
I don't mean something like this:
stageX = mc.x + mc.parent.x + mc.parent.parent.x + ....
I would like to be able to determine the movie clip stage coordinates without knowing what are its parents and grandparents etc. The goal is to be able to place the movie clip on exact place on a stage, no matter what is the nesting structure.
I have been working on Flash AS3 project. I am designing a 3D system. Consider a MovieClip A which is at (0,0,0). A contains B which is at (10,10,10). If I rotate A by 10 degrees then the position of B with respect to A remains the same but position of B with respect to the system changes. To find Global X and Y of B, we have the function localToGlobal but it does not tell anything about the Z property. How to find that?
View 2 RepliesMy stage contains an object that contains a child. The child sees it's x and y position in relation to it's parent, so when the object moves, the coordinates remain the same.
How do i get a child's coordinates relative to the stage?
Okay this is always something that's puzzled me. If I create a movieclip, place that clip on the stage, then inside that movieclip, create another movieclip, how does flash determine the coordinates of that second movieclip in relation to the stage. The reason I am asking this, is that I have a large movieclip which contains a number of other smaller movieclips. When a user clicks on one of the smaller movie clips, I need the larger movieclip to move so that the clicked movieclip is now centered on the stage.
I figure that this would be easier to know if I knew how to calculate the distance which the second, smaller movieclip is from the center of the main stage in x and y coordinate values. Am I making any sense? If not I'll try to explain again.
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.
View 1 RepliesIs it possible to use JavaScript to detect whether a .swf file has loaded completely within a web page?Assume that the .swf file is pulled from a 3rd-party website and we don't have access to its source code.
View 2 RepliesHow can I get the absolute stage position of an object within a custom flex component that I exported from flash? In my Flex application I'm using the component and resizing it by setting its height and width properties. I want to place another component on the stage but I want it to appear at the same x and y coordinates of a text field in my custom component.
newComponent.x = customComponent.myTextField.x
newComponent.y = customComponent.myTextField.y
Because the customComponent is resized, the coordinates don't match up.
I'm often finding a need to get a stage-relative position of objects in my game, which are often buried several layers deep as children of children of children, etc, often with differently scaled/moved/rotated parents. The position i want isn't quite relative to the stage, but a main holder object i have on it called lvlHolder (see code below). I wrote a function to deal with it that recurses up the display list, accounting for each object as it goes, to get a global position. It's worked so far, but one thing it doesn't account for is rotation. I'm finding a need for that now, and i'm not sure how to account for rotation of objects, to rotate offsets from them,
My function is below. how i should enhance it to accomodate for the rotation of each parent object? Also any tips on optimisation would be good, as i'm using this a LOT (roughly twice per frame, per object, for physics calculations) I'm also wondering, in similar situations i've seen something related to transform matrices used
[Code]....
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.
[Code]...
In Actionscript 3 is there any way to determine the precise display object hierarchy an event will traverse through when dispatched from a given object? The object is not necessarily a display object.Although I could imagine this actually being useful somehow, in my particular case it is a learning exercise. I'm trying to master the event system in flash and have some locations where I'm very curious what path an event will take when I dispatch it.
View 2 Repliesi'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]
View 3 Replieshow to determine if there's a dragged object. Is there a way to do this?
I know if you start another drag on the other object it will stop the current dragged object. Maybe there's a public function that will query about this?
In Java, what is the best way to determine the size of an object?
In Actionscript I can usually just do:
var myVar:uint = 5;
getSize(myVar)
//outputs 4 bytes
How do I do this in Java?
i have a class called "Ball" that extends "AllSprites" which is a class that extends "Sprite". there is an addChild within the "Ball" class that adds a Sprite to the stage. when i run it like this, it successfully adds the object to the stage.
in my Main class i have
Code:
var ballOne:Ball = new Ball();
i am trying to get the x and y value of ballOne from within my Main class but if i try to do
Code:
trace(ballOne.x);
i get an error:
1119: Access of possibly undefined property x through a reference with static type Ball.
how do i tell my code that the ballOne is a Sprite so i can get the x and y values?
also not working:
Code:
trace(Sprite(ballOne.x));
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?
View 2 Repliesif 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
Any command to check whether an object is currently present in the Display List? I have a TextField called _startHereText. I have some logic where I need to sometimes use RemoveChild to take this object out of the Display List, but I first need to determine if it is presently there.
View 9 RepliesHow can I get the X, Y, and rotation values, relative to the stage of a child of unknown number of parents?
What I am doing is: I have a 'stick' object, that creates a child 'stick', that creates a child 'stick', etc a random number of times.
The end stick then creates a leaf.
Each new stick rotates a little bit randomly.
As a result when my leaf falls off the final stick it flies off in a strange direction.
How can I get the leaf to fall down (eg y++ relative to stage)?
Alternatively I thought I could dispatch an event that has a leaf created at the stage level but then I really need to know what the X and Y co-ordinates of my final stick is realtive to the stage.
I want to find out what object is at 200x300? is there a particular command for this?
View 2 RepliesI have an object that moves when the arrows are pressed but how do i display the coordinates of the object, x and y? I tried
this.x=this.x
this.y=this.y
and then two dynamic boxes called x and y but it doesn't work!
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.
View 1 RepliesBasically 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.
View 4 RepliesI have this bit of code, and it's not working as I expected. btnContainer is a VBox that contains a ton of buttons (toggle=true); and I want to reset them to un-toggled at a certain point.
for (var btn:Object in btnContainer.getChildren()){
if (btn.isPrototypeOf(mx.controls.Button)){
btn.selected = false;
}
}
With the above code, "btn" shows up as just the index during each iteration of the loop (0,1,2,3,...), and the conditional never evaluates to true.I also tried this:
for (var btn:Button in btnContainer.getChildren()){
btn.selected = false;
}
This works fine, except that there is also a label inside btnContainer; so it throws an error when trying to cast the label as a button.
How can I get the X, Y, and rotation values, relative to the stage of a child of unknown number of parents?What I am doing is: I have a 'stick' object, that creates a child 'stick', that creates a child 'stick', etc a random number of times.The end stick then creates a leaf. Each new stick rotates a little bit randomly.As a result when my leaf falls off the final stick it flies off in a strange direction.How can I get the leaf to fall down (eg y++ relative to stage)?Alternatively I thought I could dispatch an event that has a leaf created at the stage level but then I really need to know what the X and Y co-ordinates of my final stick is realtive to the stage.
View 0 RepliesIs there a way to determine the current position of the pen in a graphics display object. Something similar to what is discussed in this thread but for AS3?
View 4 RepliesThis is probably a silly question buy how do I find out if an Actionscript Object is just an Object ,but NOT any subclass IE String bool etc?[code]...
View 1 RepliesI'm trying to place a displayobject at the bottom of the stage with scale mode set to exact fit. stageHeight returns the actual height in pixels, but the stage scaleY still returns 1.Isn't there a simple way to determine the original height for object placement?
View 6 RepliesThere 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);
[code]......
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?