A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: hitTest

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    10

    Unhappy hitTest

    I made a movie clip follow the mouse, and when it collides with another movie clip, it should gotoAndPlay a frame. But it doesn't! My code is:
    onClipEvent(enterFrame){
    this._root._x=_xmouse;
    this._root._y=_ymouse;
    Mouse.hide();
    if(this.hitTest(_root.ear)){
    gotoAndPlay(3);
    }
    I even tried putting that code on a frame in the timeline, but it didn't work either. Nothing's happening when the movie clip that follows the mouse goes over the other movie clip "ear". HELP!
    AS 2

  2. #2
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Can you upload the FLA if possible so that we can check!
    As ever,
    Vinayak Kadam

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Posts
    10
    Sure, here it is:
    Last edited by Arsenkov; 04-04-2009 at 01:08 PM.

  4. #4
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Which Flash version you use ?
    As ever,
    Vinayak Kadam

  5. #5
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Hello there,

    I managed to run your code and get the required functionality run. I made a few changes:

    1. Moved the hand movie clip on top layer.
    2. Moved the ear movie clip layer below above. I moved them on different layers so dept issues are taken care off.
    3. Made some changes in the code in the hand movie clip.

    I have attached the FLA which is saved in Flash 8. Hope this helps!
    Last edited by vinayak.kadam; 02-08-2010 at 06:14 AM.
    As ever,
    Vinayak Kadam

  6. #6
    Junior Member
    Join Date
    Mar 2009
    Posts
    10

    Thumbs up Thanks a lot!

    Thanks man, I've been trying to get that working for quite some time now! Oh, and can you please tell me why'd you use that this.enterFrame=null thing, and when should I use it? (Cause I'm still a noob in Flash, so, yeah)
    Thanks again,
    Peace!

  7. #7
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    What enterframe does is it periodically, with some time interval, keeps on repeating what ever you have written in the even handler. So what ever code was written on the hand movie clip inside enterframe handler was called repeatedly with some interval.

    Interval time is inversely proportional upon your frame rate. The more frame rate, the less interval and vice versa. Hope this helps!
    As ever,
    Vinayak Kadam

Tags for this Thread

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