ActionScript 3.0 :: Get The Absolute Stage Position Of An Object?
Jul 16, 2009
How 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.
View 1 Replies
Similar Posts:
Feb 25, 2012
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]....
View 1 Replies
Apr 23, 2010
I have a stage bigger than the size of a browser, and I have a camera to navigate around the area.Now when I click on a button, I will have something pop up blocking the whole browser, like a lightbox effect with another box on top of the blocker.The problem now is, when the blocker pops up, its position is not on the TOP LEFT corner of the browser. I've tried stage.align, but it would makes the camera or other object on stage position run.So is there any other way I could get the blocker to position according to the browser, not the stage?[code]
View 1 Replies
Sep 26, 2010
I need (convert) absolute position of nested mc (_root.mc.mc._x) on the stage. I noticed that the function localToGlobal could do this, but I could not figure out how. Maybe I could do workaround with counting positions of parent clips, but that sounds lame. how to trace this on the Stage? (trace(_root.mc.mc._x);
View 2 Replies
Aug 29, 2010
I have built a site in AS2 and would like to know the position of a ball so that I can move a sign to it always.The whole website is in AS2, but I think I have written an incomplete code below for AS3. I need it for AS2 because the whole site is in AS2. The get position of ball is wrong, but I just wanted to throw in some ideas eg.
Code:
// get position of ball
ball_mc.addEventListener(<what goes here?>, ball_pos);
function signMove(Event:MouseEvent):void{[code]..........
View 3 Replies
Nov 4, 2010
im trying to keep a object in a certain position in the screen, without resizing it too (with the stage)
function Resize(e:Event = null):void
{
if ((stage.stageWidth)/(stage.stageHeight) > fundos.width/fundos.height)
{
[Code]....
my stage is resizing all ok (keeping the aspect ratio) and im trying to add a nav img that would stay in the same position as i resize the browser screen
View 3 Replies
Dec 11, 2010
i'd trying to build an interactive tree that allows the user to move the tree's branches and nodes. the lines (branches) of the tree are drawn programmatically between points (nodes and tips). i'd like for the user to click on points to drag them while having connected lines and points move correspondingly. i've gotten this to work to some extent using the code below:
ActionScript Code:
function startMoveOa(evt:MouseEvent):void {
thisPtOa = Sprite(evt.currentTarget);
[code].....
View 2 Replies
May 17, 2011
If I have a rectangle on the stage, how do I find its top left tip (x,y) and the bottom right tip (x,y) in relation to the stage?
View 2 Replies
Oct 25, 2006
I'm using the stage object to align multiple MC's. My question is how do I affect a MC's position if I want to have it be centered on both axis but 100px away from the bottom margin instead of the top relative to the size of the window?here's my positioning code:
[AS]
navBar._y = Stage.height;
navBar._x = Stage.width/2;
tpShadow._x = Stage.width/2;
[code].....
Also if i'm using an empty MC to load external swf's, do the external swf's have to have AS for positioning as well or do I position the empty MC in the base movie?
View 1 Replies
Mar 11, 2006
i need to make a movieclips _x and _y absolute to the stage so that i can duplicate a movie clip to the _x and _y of the mc without it just duplicating to the top of the stage (did anyone get that or was my english too bad?)
View 7 Replies
Aug 29, 2006
im trying to achieve a Full Browser Flash and i want my bgimage to remain in the centre of the stage whilst other objects move round it depending on mouse movements but how would i go about centering the bgimage through AS?
View 2 Replies
Oct 27, 2009
What is the simplest way to determine absolute object coordinates in AS3?
View 1 Replies
Apr 1, 2011
Is 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.
View 1 Replies
Jan 26, 2010
Is it generally to position elements relative to other elements or in absolute values?
View 2 Replies
Feb 9, 2011
i want to take btn1 position half wwidth of own x position on stage
View 1 Replies
Jan 13, 2011
I have a sprite that I zoom out using the sprite.z property. Once the z property has been modified the sprite x and Y values do not match the stage x and y real value. So far so good and what I was expecting!
What I want to accomplish is that when the user clicks the stage the sprite tweens to where the mouse was clicked but I don't know what x and y position to send to the sprite. ( since stage 200,200 is something like 400,400 for the sprite depending on z value)
I tried Utils3D.projectVector using Matrix3D of the perspectiveProjection of the stage without success. (i.e. I get Vector3D(Infinity, Infinity, NaN))
I could fallback to scalex/scaley but sprites.z gives me the correct scale, perspective projection, paralax scrolling since I have sprites on different z level all for free. I would have to recode all that.
View 5 Replies
Nov 3, 2009
lets say i have a sprite on the stage and one movieclip inside it. now i want to tween or just set that movieclip x and/or y position according to stage position. so for example i want to set mc.y = - 100; (by which i mean -100 to stage, not sprite which mc is in.)
View 2 Replies
Feb 27, 2006
i saw a thread while ago .. that always position a movieclip in the middle of the stage even if the stage or window resize any1 can point me to it
View 3 Replies
Mar 22, 2010
I have a root stage, and a MC that is called from the root stage.Now from that MC, i will called in another MC2, and I wanted to placed the MC in the center of the stage. The reason I could not use normal ADDED_TO_STAGE at MC and define the center is because MC is not place in the exact position of the root stage (as in x, y=0). So if I would target MC2 at MC stage center, it would not be the exact center of the root stage/screen.How can I called the root stage properties rather than adding MC2 into the stage?
View 1 Replies
Feb 16, 2011
I'm trying to trace the path of an object by using setPixel on the object's position every frame in a BitmapData/Bitmap pairing. These pixels aren't showing up normally and I suspect I have a fundamental misunderstanding of the BitmapData class. Here's what I'm doing:
public var contrailBase:BitmapData;
public var contrail:Bitmap;
private var contrailColor:uint;[code].....
Using this code, the red pixels don't show up. If I initialize contrailBase to 0xFF000000 instead then I get a black screen on which the red pixels DO draw, but I need the bitmap to be transparent except for the contrail. What am I doing wrong?
View 2 Replies
Jun 11, 2010
I'm stuck thinking about the best way to go about setting a line segment's position, I have a class Line(length, angle, previous) being called from a class Polygon. Right now I have:
public class Line extends Sprite {
public function Line(length:Number, angle:Number, previous:Line = null) {
if (previous != null) {
this.x = previous.end.x;
[Code].....
View 1 Replies
Apr 9, 2009
I have 9 MC on stage with an instance of S1 to S9.
what I am try to do is position each clip beside each other on the x coordinate.
in AS2 it would be something like this
Code:
for (var d:Number = 0; d<9; d++) {
this["S"+d]._x = this["S"+d]._x -this["S"+d]._width/2
}
[Code]....
View 1 Replies
Jun 18, 2010
I have a function that I am creating. It basically grows a line from point a to point bRather that work with specific points and all in actionscript, I was hoping to drop down some movieclips to be used as waypoints. When the movie starts those mc locations are translated into variables and the mc is removed.
View 7 Replies
Aug 21, 2009
I'm having a heck of a time getting my movie clip on the stage postion where I want it (and eventually I'll want 8-10 movie clips running on different stage locations at the same time.) I've tried numerous scripts methods, this is the last one and it's still not moving out of 0 position:
this.createEmptyMovieClip("my_mc", 1);
my_mc.createEmptyMovieClip("container_mc",2);
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.loadClip("textgauge1.swf", my_mc.container_mc),{x_:371.6, y_:76};
View 2 Replies
Oct 22, 2009
I have a library swf (asset.swf), it's document class binded to Asset.as, and in the Constructor function of Asset,[code]as known to all, we cannot visit the stage attribute before the display object added to the stage.so, when my loader.swf try to load asset.swf, it throws exception and the loading come to failure is there some one tell me how to load the asset.swf? I cannot modify the asset.swf.
View 0 Replies
Oct 27, 2009
I have a movieclip thats inside another movieclip..lets call them mc1 and mc2..
the problem is that I want to get the position of mc2 relative to the stage...and not to mc1..is there any simple way to do this?
View 1 Replies
Nov 16, 2009
It this part in qeustion "if(ball._x + ball.width / 2 > 400){" should the trace function be recognised when the half of th ball moves over the 400 mark.
Its doesnt though and i dont know why?
ball.dx = 10;
ball.dy = 10;
ball.onEnterFrame = function(){
[Code]....
View 4 Replies
Sep 27, 2007
im working on a slider that i want to position to the stage according to the _ymouse. Here's the problem. I'm using some code that i really like because of the ease on it. But i'm having problems getting it to position where i want it and control it so that the top and bottom of the clip refers to the stage...if that makes any sense. I did not write the code, but i've changed it so that its vertical as you'll see. Everything "works" except aligning it to the stage according to _ymouse
[Code]...
View 1 Replies
Apr 11, 2011
var boaty:boat = new boat();
boxy.addChild(boaty);
How do I refer to the stage position (what we see on screen (might be called something else)) of a object added like this (boaty
View 8 Replies
Jul 30, 2011
figure out why the movie i just made is off stage. I just I don't want to start from scratch or move every object that is off stage onto stage. What did i do to get it here to begin with???
View 1 Replies