A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 2 of 2

Thread: Hit.Test Method

  1. #1
    Member
    Join Date
    Oct 2000
    Posts
    34

    Hit.Test Method

    Im testing the hit Test method.

    Ive got a movie which has two frames and two layers. One layer has the numbers 1 on the 1st frame and 2 on the second frame. The other layer has a rectangle spanning the two frames. My rectangle has this code in the object actions

    onClipEvent (enterFrame) {
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
    } else {
    gotoAndStop(1);
    }
    }

    I want a simple detection so when the mouse is over the rectangle it goes to frame two. This script doesn't work
    I don't understand

  2. #2
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483

    If you are using Flash MX:

    To perform collision detection between a movie clip and a point on the Stage:

    1 Select a movie clip on the Stage.

    2 Create a dynamic text box on the Stage and enter status as the instance name in the Property inspector.

    3 Choose Window > Actions to open the Actions panel if it is not already visible.

    4 In the Actions toolbox, click the Actions category, click Variables, double-click set variable, and name the variable _root.status. Then select the Expression check box for Value and enter the following code in the Value text box:

    hitTest(_root._xmouse, _root._ymouse, true)

    Flash automatically adds the onClipEvent handler.

    5 Highlight the onClipEvent action and select enterFrame as the event.

    6 Choose Control > Test Movie and move the mouse over the movie clip to test the collision.

    The value true is displayed whenever the mouse is over a nontransparent pixel.
    "A day without laughter is a day wasted." - Charlie Chaplin
    www.simplicit.co.za . lab.simplicit.co.za

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