A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: object-specific cursors

  1. #1
    I'm trying to create an effect where the cursor changes when the user rolls over certain (selectable) clips. The script works fine for a single clip, but when copied to other clips, only works for one clip, and not the rest.

    myCursor is initially offstage, so is invisible by default.

    onClipEvent (mouseMove) {
    if (hitTest(_root._xmouse, _root._ymouse, false)) {
    _root.myCursor._visible=true;
    Mouse.hide();
    _root.myCursor._x=_root._xmouse;
    _root.myCursor._y=_root._ymouse;
    } else {
    Mouse.show();
    _root.myCursor._visible=false;
    }
    }



  2. #2
    Senior Member
    Join Date
    Jul 2000
    Location
    Not on the dole any more
    Posts
    1,040
    You're in luck...I created a file that does exactly this -- you'll find it here. You should just be able to copy and paste it right into your own file, configure it and go -- instructions at the above URL.

  3. #3
    Stickman - much obliged, but I'm still wondering why my method doesnt work for multiple clips... In fact, I'm getting the same problem happening with other scripts: for example, dragging a movie clip:

    onClipEvent (mouseDown) {
    if (hitTest(_root._xmouse,_root._ymouse, false )) {
    this.startDrag(true);
    } else {
    this.stopDrag();
    }
    }


    This should be straightforward, as far as I can see, but again, only works for one clip on stage. When copied to other clips, it does nothing.

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Location
    Not on the dole any more
    Posts
    1,040
    Well, for the first instance, if you have more than one movie clip, only one will have the mouse over it at any given time (unless the clips are overlapping). So you'll have one telling myCursor to be visible, but then all our others telling it to hide.

    In the second case, the StopDrag will never happen (once the start drag has activated) because the movie clip will always be under the mouse -- because it's being dragged. And you can only drag one clip at a time.

  5. #5
    thanks for the explanation - I realised that my drag script was just too simplistic - it works with the addition of the on Mouse up statement.

    However, with regard to the original example, I seem to be misunderstanding the Hittest:

    if (hitTest(_root._xmouse, _root._ymouse, false))

    This seems to be saying: only execute this script if the mouse is over -this- movie clip. Or have I got it wrong?

    thanks for your time.

  6. #6
    Senior Member
    Join Date
    Jul 2000
    Location
    Not on the dole any more
    Posts
    1,040
    No, the 'false' in this case relates to a how the hitTest will work -- this from the AS dictionary:

    anyMovieClip.hitTest(x, y, shapeFlag);

    shapeFlag A Boolean value specifying whether to evaluate the entire shape of the specified instance (true), or just the bounding box (false)
    You'd need something like

    Code:
    if (hitTest(_root._xmouse, _root._ymouse, false) = false)

  7. #7
    OK, I can now see the flaws (more like chasms) in my logic. Teaching yourself to write code isn't always easy.

    Thanks again for the solution. The use of droptarget to detect the movie under the mouse is great - hadn't occured to me to use it that way.

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