Skip to main content
Inspiring
July 21, 2025
Question

how to get a addchild command to grab the x and y postions from its own symbol

  • July 21, 2025
  • 1 reply
  • 167 views

 how do i tell the addchild command to look at the symbol its loading to get its coordinates for placement

vs 0,0 i recall which is its default.

 

this is the step thats causing me grief on reloading animations as right now it looks like i got a triple dymo labeler (piece name, x position y position and if i can get THAT figured out, i only one have one a to z wheel spinning in my code wheel vs 3. 

 

the game files i'm rebuiding have a placeholder symbol swf and about 400 swfs taht the pieces are also in that placement, and my plan is to put a filename in front and store that in a variable....saving me making individual avatars, just call the color and species and its off to the races! 

 

what i found out by frustration was copying the individual symbols to the artboard using the x y coordinates is that the master piece that they built the animations is mostly off the artboard(and were deleted afterwords).....and get that piece the slightest bit off and you get interpretive art....

 

 

 

 

 

 

    1 reply

    kglad
    Community Expert
    Community Expert
    July 21, 2025

    addChild loads nothing.  it adds something to the display list.

     

    the parent x,y are relevant abd the child's x,y are assignable.

     

    so, what problem are you having?

    Inspiring
    July 22, 2025

    how do i get the parent x,y to place where they are when doing the addchild command, rather than being assigned at 0,0

    this would leave me with less than 2 variables to deal with as all the objects are where they need to be already. so getting the locations from the symbol would make neater code. 

    thius is how i'm visualizing this code so far 

     

     

     

     

     

     

     

     

     

     

     

     

     

    only need to call the symbol itself to get it where it needs to go

     

    kglad
    Community Expert
    Community Expert
    July 22, 2025

    just assign their x,y

     

    if you know what x,y relative to the stage ( 0,0 upper left, stageWidth,stageHeight lower right), you can just use:

     

    function positionF(_parent:DisplayObjectContainer, _child:DisplayObject, _x:int, _y:int):void{
    _parent.addChild(_child);
    _child.x = _x-_parent.x;
    _child.y = _y-_parent.y;
    }