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
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?
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
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.
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.
i was wondering if there was something that allowed you to grab any 2d point that exists inside a movieclip and grab the 3d position of that exact point...
for example i have a rectangle movieclip on the stage .. and its rotate on the x axis 75 degrees.. registration of the clip is at bottom middle.. so when it rotates the bottom stays in the same spot and everything rotates around it..
now what if i wanted to know the exact x,y,z of the top edge of the clip..
is there a function similar to localToGlobal that would take the x,y coordinate inside the clip and spit back a global 3d point .. (i guess its called a Vector3D)
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?
In Flex/Actionscript.When writing an on mouseMove event on a Canvas control for example, how could I check to see what control if any is under the mouse pointer at a particular coordinate?
i have a parent movieclip mcA and i want to add another movieclip mcB (child movieclip) inside mcA such that the extra part of mcB is hidden. The size of movieclip remains same as of mcA
For ex:-
mcA = 300x300 mcB = 400x400
then only 300x300 of mcB movieclip is visible and rest of the part is hidden.
I added a Menu_mc on my stage. Initially, this should be at the center of the stage and when I click on it, it will tween on the upper left corner of the browser. However, when I resize the browser, the Menu_mc goes back to the center of the screen.
I have tried separating a different actionscript file where it is specifically for initialization of the object and another one for resizing. And then when I call it on my main AS file it goes like this:
Code: // Add the symbols to stage var Menu_mc = new Menu_MC(); addChild(Menu_mc);
I'm hoping someone can solve this headache. Basically, I want a movieclip to move to the position of each of my buttons from any position along my x axis. Therefore, the movieclip needs to 'flip' to face the way it is traveling.At the moment I have the movieclip moving to the mouse x axis when I ROLLOVER the button and stop following the mouse when I ROLLOUT but the code won't flip the movieclip so I must have something wrong...
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.)
What i'd like to do is have a menu/site map that adjusts when you click on a certain icon. For example, I have a AS3.0 flash file with, say, 5 keyframes with 5 buttons that are in different positions on each key frame. The buttons are set to gotoAndPlay the various keyframes. I can set up a tween that links frame 1 to 2, 2 to 3 etc. but what I would like is a tween from, say, 1 to 3, then 3 to 5, then 5 to 1 - basically in a random order rather than sequentially through the key frames. I could set each of these tweens up individually but the site is for a portfolio that I would like to keep adding to and to do this individually would mean an ever increasing amount of tweens.Basically, is there a way to get a 'MovieClip' to move from Position A in keyframe 1 to Position B in another keyframe without a set of tween frames? I'm sure this is simpler than I am making it sound but I don't seem to be able to work it out.
My problem is I wish to find the x and y position of certain child objects. however when i try to display these values I am only shown their position when the child is initially added to the stage.Once the child moves due to the parent object moving, visually the child is moving, however when tracing or displaying the childs x position it remains static.Here is an abstracted version of my problem, it is all code based so it should run fine. The problem area is highlighted using comments and you will notice that the child positions in the trace logs do not change.
I can have the parent move the position of the child by adjusting its _x and/or _y. The child can move itself along the x axis by using _parent[childname]._x = but I can't get it to move along the y axis using _parent[childname]._y = , it just doesn't move.
I could not find this one. So say a movieclip is called Background.I have some code in its timeline's first frame and i want to use trace to print its prototype/identifier name.how can i do it?could not find anything even on googling.May be I'm searching for the wrong keyword.
What I mean to find out is what is shown in the Identifier section of the symbol properties.
I have 3 instances of the same movieclip (let's call it mc1). In that movieclip is a different one (mc2). In the class for mc2 i need to find out the instance name of which instance of the mc1 it is in.
Is there a way I can I get the name of the instance of mc1 that mc2 is in?
Is it possible to get a reference to all the movieclips I might have added to a movieclip in the designer. Lets say I want to do this in the onLoad function of the movieclip. I couldn't find a way to do it.
I'm writing a game with Flash CS5/AS 3.0 that tries to simulate depth of field by drawing all the relevant Movie Clips based on their Y position in ascending order, i.e. things lower on the stage overlap things higher on the stage. A MovieClip with a Y position of 10 would therefore need to have a lower index compared to a MovieClip with a Y position of 20, so the second one gets drawn on top of the first.
I wrote a quick and dirty function just to test this. During the trace, I've noticed that the truck's index hits 0 when I go near the top of the stage, but if I go too far up it will completely disappear from the stage. Trace then starts generating this error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/getChildIndex() at EICT::Game/ReorganizeDisplayIndexes()
I have a fairly complex form page and there's one MovieClip that's misbehaving. It's quite a bit of code so I'm having trouble locating where it's being generated from because the page is fairly dynamic.I'm looking for a sort of MovieClip.prototype-esque way of trace()ing the name of any clip that's clicked in a global fashion. Thus when I click and the misbehaving movieclip is firing off I can figure out who/what it is.
I find that when I override the prototype of any part of MovieClip that it renders other elements unusable. For example I tried to just override onReleaseOutside temporarily to see if I could get the clips name but it also disabled onPress, onRelease, etc and everything stopped working.
Imagine two movieclips, both on the same Y axis. I want one MC to be able to diagonally move to the other MC X axis, all while making a perfect diagonal line until it reaches 100y. So just like this picture, that MC moves in a perfect diagonal until it matches the other MC.x, and 100y (no matter what, it can't go past 100y but must equal 100y). I probably made it sound more complicated than it is.
using the following jumpTo script as a guide how do I write an if statement for a function that will basically ask "if the movieclip is at position 3 stay there, otherwise jumpTo position 2"?
Code: var bg1x = new Array(0, -1280, -1014, 0); function jumpTobg1X(number) { gradientNav_mc.newX = bg1x[number]; }
I have tried a bunch of if/else statements but I can't get it working. I can't figure out how to write it properly. I tried something like this:
Okay I have a script in which I have added an image to the stage. It is absolute centered. I then have another with is on top but much bigger. I would like the big image to move opposite of my mouse position on the smaller image. ie: cursor is on bottom left corner the bottom left corner of the larger image is in the same spot. And the same thing for any other area.
I have tried many different ways but to no avail. I have done research but no one has been able to give me a solid answer. Anyone know of a way to accomplish this. Keep in mind this it needs to work regardless of the image size.