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

  1. #1

    Default hitTest coordinates

    Hi there,

    I have a problem wit ha complex call to 'hitTest' to test a point collision.
    Which coordinates does the clip.hitTest(x,y) use? Are they rel;ative to the
    'center' of 'clip' ?

    I have a several nested clips. I have a 'track' which has a hit area clip for
    the grass:
    _root.track.grass
    I also have a car on the track, and a clip on the car to use as the 'collision
    point':
    _root.track.car.coll_point

    I get the hitTest coordinates for the 'grass' clip like this (from object
    'Car'):
    p = new Object();
    p.x = coll_point._x;
    p.y = coll_point._y;
    this.localToGlobal(p);
    _root.track.grass.globalToLocal(p);
    _root.track.grass.hitTest(p.x, p.y);

    However, this doesn't provide the correct coordinates for the hit test, even
    though the point 'p' within 'grass' is correct. I know it is correct because I
    can place a clip at that point and see that its in the correct place:

    mark = _root.track.grass.attachMovie('marker','aMarker',2 00);
    mark._x = p.x;
    mark._y = p.y

    This shows that the point 'p' on the 'grass' track is correct!
    If it helps, the 'track' clip is moved all over the stage to keep the 'car'
    clip in the center...
    Any ideas as to why this doesn't work?

    Cheers,
    Pea

    Pea 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. hitTest
      Hello, my name is alex, and i am sort of a "Newbie" at action script, and i was trying to creat a hit test, so that when the "Axe" hits the guys...
    3. hitTest()
      I have a MovieClip with one transparent bitmap inside. When I do hitTest(x, y, true) on an instance of that clip, the bitmap's square area is...
    4. hitTest with true
      I'd like to create a hitTest betweeen two irregularly shaped mc's - To use the actusl pixels rasther than a bounding bov I need to put True as a...
    5. hittest: nested MCs
      I have multiple dynamically duplicated objects, called "units". Let's say I have 2 at the point this code is executed: ...
  3. #2

    Default Re: hitTest coordinates

    Hi all,

    I should have taken my own advice for a post I just did and RTFM myself....
    For any interested, the hitTest coordinates are in 'global' space (using
    localToGlobal) and says so clearly in the help.

    Cheers,
    Pea

    Pea 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