A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: cursor help

  1. #1
    Member
    Join Date
    Jul 2004
    Location
    In a house
    Posts
    37

    cursor help

    Hey! I'm making a game and need help.

    Can you make me a code that would change to frame 20 in the timeline when a movieclip called "knife" touches my cursor?

    If you could, GREAT! I'm a n00bie!
    ----------------MRD Media---------------
    --------------------------------

  2. #2
    Pedro
    Join Date
    Nov 2003
    Location
    UK
    Posts
    69
    I'm not going to spoon-feed you the code because you'll learn better if you do it yourself, also, I can't remember it.

    But, do a hit test inside an IF control structure. If it's true, use gotoAndPlay() ot gotoAndStop(). Check the ActionScript dictionary for more info.
    "I feel like a king!"

  3. #3
    Junior Member
    Join Date
    Aug 2004
    Posts
    12
    I disagree. I know I'd never have been able to learn proper AS if all people would do is give me 'hints'..

    Code:
    onClipEvent(enterFrame)
         if(this.hitTest(_xmouse, _xmouse) {
              _root.gotoAndStop(20);
    }
    If you put that inside the knife MC, it should work.

    ***
    Another method is to make another small, invisible (set it's alpha to 0) MC, and set it to follow the mouse with the code:
    Code:
    onClipEvent(enterFrame) {
         this._x = _xmouse;
         this._y = _ymouse;
    }
    (put that inside the small, invisible MC)
    Then give that small, invisible MC an instance name, I'll use 'mouseHit' for this example. Then place the following code inside the knife:
    Code:
    onClipEvent(enterFrame) {
         if(this.hitTest(_root.mouseHit)) {
              _root.gotoAndStop(20);
         }
    }
    A bit of explanation: The code used for determining wether one thing hits another is
    'if(OBJECT1.hitTest(OBJECT2)) {
    WHAT YOU WANT TO HAPPEN
    }'

    Mmkay?

    Good luck with your project.

  4. #4
    Member
    Join Date
    Jul 2004
    Location
    In a house
    Posts
    37
    Originally posted by BodadeM
    I disagree. I know I'd never have been able to learn proper AS if all people would do is give me 'hints'..

    Code:
    onClipEvent(enterFrame)
         if(this.hitTest(_xmouse, _xmouse) {
              _root.gotoAndStop(20);
    }
    If you put that inside the knife MC, it should work.

    ***
    Another method is to make another small, invisible (set it's alpha to 0) MC, and set it to follow the mouse with the code:
    Code:
    onClipEvent(enterFrame) {
         this._x = _xmouse;
         this._y = _ymouse;
    }
    (put that inside the small, invisible MC)
    Then give that small, invisible MC an instance name, I'll use 'mouseHit' for this example. Then place the following code inside the knife:
    Code:
    onClipEvent(enterFrame) {
         if(this.hitTest(_root.mouseHit)) {
              _root.gotoAndStop(20);
         }
    }
    A bit of explanation: The code used for determining wether one thing hits another is
    'if(OBJECT1.hitTest(OBJECT2)) {
    WHAT YOU WANT TO HAPPEN
    }'

    Mmkay?

    Good luck with your project.
    THANKS very much! If not for you, I would still be back at step 1...
    ----------------MRD Media---------------
    --------------------------------

  5. #5

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