A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [prob] referencing _x and _y

  1. #1
    The epitomy of hip
    Join Date
    Jun 2004
    Location
    United States of America
    Posts
    77

    [prob] referencing _x and _y

    i wrote a long question but the attached file was too big and it got deleted by my browser. this is short and to the point because I am quite annoyed

    how do you tell the _x and _y of an MC inside an MC from the view of the stage? there is an MC with an MC inside it. the first MC's x and y are 50 50. the one inside is 50 50 from its point of view inside the first MC. from the stage it looks llike 100 100 but actionscript recognizes it as 50 50. hmmmm.... ? any suggestions

    sorry for short post. running out of time because of parental controls on AOL

    !
    Last edited by uhmazuhn_aashun; 11-10-2004 at 12:33 AM.
    J
    A
    Z
    Z

    Can you dig it?

  2. #2
    Run for your life! Phlook's Avatar
    Join Date
    Jul 2003
    Location
    Vancouver, Canada
    Posts
    679
    You have to use...
    code:

    point = {x:this.embedded_mc._x, y:this.embedded_mc._y};
    localToGlobal(point);



    I think thats the way it works, its been awhile since i used it
    Last edited by Phlook; 11-10-2004 at 10:41 AM.

  3. #3
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,182
    That's because the movie checks the _x and _y of the inner MC where the + sign of the outter MC is. So that would mean the _x and _y of the inner MC never change, if you only move the outer MC.

    If you want to know what the _x and _y of the inner MC is according to the upper left corner of the movie, you can use this code:
    code:
    trace(outerMC._x + innerMC._x);
    trace(outerMC._y + innerMC._y);



    SaphuA

  4. #4
    The epitomy of hip
    Join Date
    Jun 2004
    Location
    United States of America
    Posts
    77
    Thank you Phlook and SaphuA. Phlook, I am not familiar with the:
    code:
    point = {x:this.embedded_mc._x, y:this.embedded_mc._y};
    localToGlobal(point);


    actionscript. Sorry, could you explain what "point" represents and how would I reference to it? Like this?
    code:
    _x = point.x
    _y = point.y


    Oh and Saphua, the first MC, the outer "shell" of the hierarchy, rotates because it is a spaceship that the user controls. Sorry that I didnt include that in the last post, but it makes it harder to pinpoint the position of the inner MC's position because when the MC rotates, the inner one stays in the same position relative to the layer (MC) that it is in, but moves on the stage.

    Thanks guys
    J
    A
    Z
    Z

    Can you dig it?

  5. #5
    Run for your life! Phlook's Avatar
    Join Date
    Jul 2003
    Location
    Vancouver, Canada
    Posts
    679
    My method, takes a point with both x and y coordinates, and converts them from local co-ordinates (within the mc) to global(stage) co-ordinates

    then youd use it like

    code:

    point = {x:this.embedded_mc._x, y:this.embedded_mc._y};
    point2.localToGlobal(point);
    _x = point2.x;
    _y = point2.y;


Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center