MC absolute coordinates?

Ask a Question related to Macromedia Flash Actionscript, Design and Development.

  1. #1

    Default MC absolute coordinates?

    When you have nested MCs, the coordinates of a nested MC will be relative where it is in relation to the reg point of its parent MC. Is there a way to get the absolute _x and _y coordinates of a nested MC? In other words, find out where the reg point of an MC falls on the _root timeline even when it's nested?

    TIA

    -beally-
    -------------------------
    "Senior Member" - experienced at messing things up
    CurrentProject - feedback appreciated
    abeall webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. Convert user space coordinates to device coordinates
      Hi, I need to convert the coordinates of a word (PDWord object) to device coordinates (the actual coordinates on the screen). Could someone please...
    2. x and y coordinates
      Is there a way to enter the x and y coordinates of an object to change its position on the page. I see the info pallette gives the x and y...
    3. absolute coordinates
      hi all, I hope this is not a silly question, but I would a) like to display the position of an object in absolute coordinates and b) enter manually...
    4. absolute or relative _x/_y coordinates
      Hello friends, allrite here it goes. I have three clips. Lets call'em: clip0,clip1 and clip2 clip1 is INSIDE clip0
    5. Some help with coordinates please!
      Hullo! Ok, so, I have this friend (clichè? no, no, I swear it's true!) that has a problem. I thought i could help her but I couldn't after all. ...
  3. #2

    Default Re:MC absolute coordinates?

    UPDATE

    the obvious solution would be to add the parent coordinates to the child coordinates, and the sum should be the child's _root coordinates. The problem is, if the parent is rotated, the child(if not directly at reg point of parent) will be moved on the _root but not on the parent, so the above wont work. I have figured out a really round about way to counter this using calculus, but is there no absolute coordinates function?

    -beally-
    -------------------------
    "Senior Member" - experienced at messing things up
    CurrentProject - feedback appreciated
    abeall webforumsuser@macromedia.com Guest

  4. #3

    Default Re: MC absolute coordinates?

    "abeall" [email]webforumsuser@macromedia.com[/email] wrote:
    Q > When you have nested MCs, the coordinates of a
    nested MC will be relative where it is in relation to
    the reg point of its parent MC. Is there a way to get the
    absolute _x and _y coordinates of a nested MC? In other
    words, find out where the reg point of an MC falls on
    the _root timeline even when it's nested?


    A : check MovieClip's localToGlobal method

    In your case the solution would be - provided that your root is
    not scaled nor moved - something like for instance :

    var p={x:0,y:0};
    parentMc.anotherMc.mc.localToGlobal(p);

    // or

    var path = parentMc.anotherMc;
    var myMc = path.mc;
    var p={x:myMc._x,y:myMc._y};
    parentMc.anotherMc.localToGlobal(p);

    then to retrieve these absolute coordinates in any mc
    coordinate space:
    anyMc.globalToLocal(p);

    you could also try something like:

    MovieClip.prototype.getAbsoluteCoordinates = function () {
    var p= { x : this._x , y : this._y };
    this._parent.localToGlobal(p);
    return p;
    };
    MovieClip.prototype.getLocalCoordinates =
    function (/*MovieClip*/ targetMc) {
    var p= { x : this._x , y : this._y };
    this._parent.localToGlobal(p);
    targetMc.globalToLocal(p);
    return p;
    };

    // sample code:
    d.onEnterFrame=function() {
    var p = a.b.getLocalCoordinates(d);
    d.c._x=p.x;
    d.c._y=p.y;
    };
    // on the root timeline clip b is nested in clip a
    // and clip c is nested in clip d
    // suppose b has a motion tween within a
    // both a and d can be rotated and/or scaled
    // and/or skewed and
    // no matter how deep mc's are nested


    NB: getBounds doesn't answer specifically your question but
    is in some way related since it takes a "target
    coordinate space" parameter, you couldn't achieve the
    same result - but it might be useful.

    HTH,

    --
    Bertrand Saint-Guillain
    [url]http://www.supersatori.com/[/url]
    Bertrand Saint-Guillain Guest

  5. #4

    Default Re: MC absolute coordinates?

    hey

    still haven't gotten around to trying this idea out, it looks complex, but I'll give it a shot.

    let me see if I get this. the localToGlobal method takes a point object, and will convert it to a global point?

    I'll try it out, thanks

    -beally-
    -------------------------
    "Senior Member" - experienced at messing things up
    CurrentProject - feedback appreciated
    abeall webforumsuser@macromedia.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139