dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Collision testing help please!

  1. #1
    Junior Member
    Join Date
    Oct 2002
    Posts
    5

    Collision testing help please!

    OK, im really annoyed at this so Im posting for help. I have an assignment, create a movie clip cursor that will use the hit function when it runs over another movieclip. I have my movieclips, "cursordrag" and "Alpha". According to the code Ive read in all the posts about hittest, this should work:

    Code:
    if (hitTest(this,_root.Alpha)) {  _root.gotoAndPlay (55); }
    where 'this' is the MC taking place of my mouse, Alpha is a stationary rectangle MC on the same layer as 'this'. Frame 55 is a sound clip on another layer.

    The MC in place of the mouse works. However, no matter how much I move my mouse over Alpha, nothing happens.

    Please help!

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Attach this as a clip event to your mc that is replacing the mouse pointer

    onClipEvent(mouseMove) {
    if (!playingClip) { // prevent the gotoAndPlay action running continuously
    if (this.hitTest(_root.Alpha)) {
    _root.gotoAndPlay(55);
    playingClip = true;
    }
    }
    }

    Then at some point later you may want to reset the variable playingClip back to false to allow the rollover to work again.

    _root.instanceNameOfDraggedClip.playingClip = false;

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