A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] [Help] localToGlobal Issue

  1. #1
    Member
    Join Date
    Dec 2005
    Posts
    61

    resolved [RESOLVED] [Help] localToGlobal Issue

    Hello,

    Using Flash 9 with AS3...

    This is a quick example of an issue I'm experiencing in a current project. I've used localToGlobal before but never in this situation with MCs within MCs within MCs....

    There is a map mc then within the map there are three section mcs. Within each section there is a single unit MC. When you click on the unit mc a property movieclip will open at the mousex and mousey. This is correct... the problem is I want the same thing to happen when you select the unit from the datagrid. The starting coordinates to display the property mc would be the mc.x and mc.y of that unit. I just can't get the localToGlobal portion of the code working.

    Below is an image of what the example looks like. The top is when I click on unit 1. The property MC is shown correctly. The second image shows when I selected unit 1 from the datagrid... the window is not anywhere near unit 1 mc.

    Any help is appreciated...
    Brent



    click here to view source FLA
    Last edited by Battlespace; 11-17-2007 at 05:23 PM.

  2. #2
    Member
    Join Date
    Dec 2005
    Posts
    61
    Forgot to add that the source FLA is attached in the link below the image...

    Thanks again for any help,
    Brent

  3. #3
    Member
    Join Date
    Dec 2005
    Posts
    61
    still no luck here...

    Do I need to do multiple localToGlobal between all of the MCs?

    Thanks,
    Brent

  4. #4
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    You need to define the local object in your 'localToGlodal' statement...

    myGlobalPoint = myLocalObject.localToGlobal(point);


    Code:
    var clickPoint:Point = new Point(evt.target.data.mc.x, evt.target.data.y);
    var globalPoint:Point = evt.target.data.mc.localToGlobal(clickPoint);
    prop_mc.x = globalPoint.x;
    prop_mc.y = globalPoint.y;

  5. #5
    Member
    Join Date
    Dec 2005
    Posts
    61
    Thanks for your help...

    With just a little modification that worked great for me...

    I fixed the typo here:
    Code:
    evt.target.data.y 
    to 
    evt.target.data.mc.y
    after this it was really close but not right on the x, y of the mc (upper left corner).

    Once I changed this line:
    Code:
    var globalPoint:Point = evt.target.data.mc.localToGlobal(clickPoint);
    
    to
    
    var globalPoint:Point = evt.target.data.mc.parent.localToGlobal(clickPoint);
    It started working great...

    Thanks again...
    Brent

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