ActionScript 3.0 :: Finding Absolute Position Of An Object

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


Similar Posts:


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

Actionscript 3 :: Finding An Object's Position In An Array In Actionscript?

Jun 9, 2010

var array1:Array = new Array();
var array2:Array = new Array();
var obj1:Object = new Object();
array1.push(obj1);
array2.push(obj1);

How can I do this what command should I use?

//obj1's position in array1
//result: 0
//obj1's position in array2
//result: 0

View 1 Replies

ActionScript 2.0 :: Absolute Position Of Nested MC?

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

Flash :: Determine Absolute Object Coordinates?

Oct 27, 2009

What is the simplest way to determine absolute object coordinates in AS3?

View 1 Replies

Professional :: Position Elements Relative To Other Elements Or In Absolute Values?

Jan 26, 2010

Is it generally to position elements relative to other elements or in absolute values?

View 2 Replies

Flex :: Finding X,y Position Of A Datagrid / AdavancedDataGrid Row

Feb 27, 2010

I have flex advancedDataGrid (could use dataGrid if that works better, though i like my meta-column headers), and i want to have a component popup on top of a selected row.

The problem is, i can figure out how to reference an actual rendered row of a datagrid (rather than an item of the dataprovider) in order to get its position on the screen.

how to access a "row" of a datagrid, or at least get its position?

View 3 Replies

ActionScript 3.0 :: Finding Position Of A Child Movieclip?

Nov 11, 2010

How does one find the position of a child movieclip within a parent movieclip relative to the stage? Whenever I refer to the position of the target movieclip, it gives me a number of what I'm not quite sure it refers to. I want to know the position of a an object as it is seen drawn on the stage

View 5 Replies

ActionScript 2.0 :: Finding Out Position Of Elements In An Array?

Dec 24, 2006

how do you find out in which position a certain value is in an array?

View 9 Replies

ActionScript 3.0 :: Finding Mouse Position WITHOUT An Event?

May 3, 2009

I'm trying to get the position of the mouse while it is stationary. For example, if the SWF loads and the mouse is already on the SWF, how can I detect it's position WITHOUT waiting for the user to move the mouse.

how to grab the mouse position when the mouse moves, just not how to obtain that info when it has not moved yet.

View 1 Replies

Flash :: Finding The Position Of Occurrence Of A Word In A String

Jun 10, 2011

I have a pipe delimited string "Y|Y|Y|N|N". How can I find the position of first occurrence of N using code after processing the string.

View 4 Replies

Actionscript 3 :: Finding A Pixel Position (x And Y Coordenate) Within A Bitmapdata

Feb 22, 2012

How can I find a pixel position, based in its color, within a bitmapdata?Say, we have a path drawed (a movieclip), we make it a bitmapdata.The path´s color is red.How can I find a given pixel red, within that bitmapdata?

View 1 Replies

Finding Where An Instance Of An Object Is Placed?

Mar 7, 2011

I need to find an instance of a movieclip that is on my flash file. It is really big and uses a lot of memory. It says on the number of times used that there is one instance of the object on the flash file, but I can't find it. I thought I deleted them all but there must be one left. How do I go about finding it? It's a really large flash file with many layers, and I don't want to just delete the library file. Is there any way I can find where the object is placed in my file?

View 2 Replies

Finding Object At X And Y Coordinates

Oct 16, 2009

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 Replies

Professional :: Finding An Object's 'path'

Jun 30, 2010

I'm trying to write a plug-in for Flash CS5 that will display the "instances path" for a selected object. I'm trying to work with JSFL.I manged to get all selected objects using fl.getDocumentDOM().selection. I iterate over the array I get and look at the objects. I am able to get each of the objects' name. What I need to do is construct the "path" to that object (e.g., scene.scene.instance4.myText). Can anyone think of a way to do that? Is there a way to get the object that contains a certain object?

View 5 Replies

ActionScript 3.0 :: Finding All References To An Object?

Aug 12, 2009

* Is it possible to create weak references to objects (like theventListener/EventDispatcher is able to do) so that if they are removed, you won't be stuck keeping a reference and taking up space to something that should be garbage collected?* Is there any way to find out how many active variables are referencing a certain object? This would be handy to actually create weak references, since, if you for example, have a static array containing all objects created in that class, you can do a regular check to see if there is only one remaining reference, and if so, you can safely remove it.

* Also, might there be any way to list the entire space (one big chunk of binary data, most likely) of every variable currently running in the program, all references, basically, what Flash is currently storing in RAM?I'm pretty sure that Flash (as crappy and lacking as it is in so many areas) does not have anything like any of these built in, but hopefully there is at least something.

View 3 Replies

Flex :: WebOrb - Finding URL In Remote Object

Oct 19, 2010

Since Flashbuilder does not support WCF over https, I am considering to use weborb remoting as alternative, but not really sure how flash is going to know weborb location, if they are sitting on different servers. Looked at destination, source fields, but not really find a field called url in remoteObject in Flex.

View 1 Replies

Flash :: AS3: Finding The Child Object You Are Clicking On

Jan 10, 2011

I have a menu MovieClip that has its buttons inside of it. I have the menu with a MousEvent.CLICK and trying to figure a way to register what you are clicking on.

[Code]...

View 2 Replies

ActionScript 3.0 :: Finding If Line Passes Through Object?

Jun 21, 2009

I have two points and an object with a given width(or length). I'm trying to find out if the line between those two points passes through the object.

View 3 Replies

ActionScript 3.0 :: Finding Parent Array Of Object?

Aug 21, 2009

There is most certainly as easy way of doing this, but for the life of me I can't find it.

How do I determine the array name of an object i.e. when I hover over a certain clip on stage, I want to identify which array it is from.

View 2 Replies

Flash :: Finding Correct Scope Of An Object For A Callback?

Dec 11, 2009

I'm working on writing a tweening class in as2 that has a callback variable and I can't seem to find a good way to get the scope without specifically passing in a scope variable as well. This tweening class needs to work in classes as well as on the timeline. Here's what my codes looks like right now.params.scope[ params.onComplete ]( params.onCompleteParams );params is an object passed into the class. This works but I don't want to have params.scope in there.

View 1 Replies

ActionScript 3.0 :: Switch Statement - Finding Out Type Of Object

Jun 20, 2009

I want to find out which type an object has. Therefore I thought of the 'switch' statement, but how would you do that? The following code does not work, but you will get the point of what I want to do.

Code:
switch (object) {
case is String:
trace("string");
case is Array:
trace("array");
[Code] ....

View 1 Replies

Flash :: Finding Closest Object In Proxmity To Mouse Coordinates

Mar 30, 2010

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]

View 3 Replies

ActionScript 3.0 :: Trace The Path Of An Object By Using SetPixel On The Object's Position Every Frame In A BitmapData/Bitmap Pairing?

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

ActionScript 3.0 :: Finding A Flash Library Object's Base Class At Runtime?

Feb 9, 2009

determine the base class of a Flash library object at runtime, using Actionscript? The toString method gives me the class of the object, but what I'd really like to determine is the superclass of the object. So, if I have an Actionscript class called "Fruit" and I created many different Fruit types in the Flash library ("Cherry", "Apple", etc.), is there a way in code I can determine that an "Apple" is a child of "Fruit"?

View 2 Replies

ActionScript 2.0 :: Have A Function Draw A Box Around An Object By Finding The Objects Instance Name Via A String?

Jun 5, 2006

Is there a way to have a function draw a box around an object by finding the objects instance name via a string?

such as:

Code:
function BoxObject(object) {
//code to draw a box around the object
}

and then juts have an object with an instance name, like "my_mc" and then call the function on a keyframe like:

BoxObject("my_mc");

View 10 Replies

Oop :: Manually Setting Object's Position Or Have The Object Do It All?

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

Flash :: Finding The Correct Scale Value Within A Scaled Object To Maintain The Aspect Ratio Of A Video

Jan 20, 2010

I have a video inside of another movieclip. When I go full screen, I scale up the outer movieclip to fit the screen. So that OuterMovieClip.width is equal to screenWidth etc. How do I maintain the aspect ratio on my video so it does not get distorted? Whats the proper math for that?

View 1 Replies

Display Position Of X And Y Of Object

Apr 19, 2009

hey guys i have 6 moveable objects, what i want is to be able to click a button and a text field appears that displays the x and y co-oridinates off each object, is this possible and if so is there a way also i could have another button where the user inputs the numbers he wants from x and y and the objects will go to that posisition

View 1 Replies

ActionScript 3.0 :: X, Y Position Of Object?

Oct 29, 2009

I am wondering about the x, y position of objects. I place a shape at a the bottom of the stage, but then when i check its x, y coords its at 0, 0. Is this correct? so when i start to move it it starts from where i want it on the stage (at the bottom) but the x,y coords are starting at 0,0 also.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved