A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: detecting the mouse position

  1. #1
    Member
    Join Date
    Jun 2000
    Posts
    93
    I am new to Flash 5. I am a Flash 4 novice, so please bare with me. I don't quite understand how to use the actionscript in Flash 5.

    I can't seem to figure out how to get the mouse location and store it in a variable to be displayed in a text box. What I am trying to do is display a numeric representation of the location of the mouse while it moves.

    Thank you,
    ~~~Evilmoose~~~

  2. #2
    Senior Member Leo Lima's Avatar
    Join Date
    Jul 2000
    Location
    São Paulo, Brazil
    Posts
    745
    have the dynamic box named something like varx and vary
    then at the movie clip, anytime you wanna update the value, you can go:
    onClipEvent (enterFrame) {
    varx = _root._xmouse;
    vary = _root._ymouse;
    }

    that will trace the position of the mouse relative to the _root. to change the scope, change the path like
    varx = _root.myMC._xmouse;

    Regards,
    Leo Lima

  3. #3
    Member
    Join Date
    Jun 2000
    Posts
    93
    Thanks for the help Leo. I got what you are saying, but i don't even know how to begin making Flash 5 do what you told me. The whole programing of actionscript in Flash 5 evades me.

  4. #4
    Senior Member Leo Lima's Avatar
    Join Date
    Jul 2000
    Location
    São Paulo, Brazil
    Posts
    745
    Hum... let's begin from the beginning :P.
    Where are the textfields?
    If they're at _root (_level0 or / to flash4's), you'll need to make a controller MC. If they're inside anyMC, you only need to setup the MC actions of that movie to update the value on enterFrame.
    Gonna try to explain:

    For both examples, varx is the variable name for the x mouse and vary for the y mouse.

    For the boxes at the _root.
    - Create an empty MC;
    - Place the MC at the stage and select it;
    - Open the Actions panel/window;
    - Type this (when in Expert mode) or paste this to that window:

    onClipEvent (enterFrame) {
    _root.varx = _root._xmouse;
    _root.vary = _root._ymouse;
    }

    - You're ready to go.

    For the boxes at anyMC.
    - Select the clip that contains the boxes;
    - Open the Actions panel/window;
    - Type this (when in Expert mode) or paste this to that window:

    onClipEvent (enterFrame) {
    varx = _root._xmouse;
    vary = _root._ymouse;
    }

    - You're ready to go.


    That should work. Tell me if you still need an example.

    Regards,
    Leo Lima

  5. #5
    Member
    Join Date
    Jun 2000
    Posts
    93
    I can't get the action script window to take text. I can't make the actionscript window do anything I want it to do. I don't know how to use the actionscript window. I hope that clears up how little the knowlege I have.

  6. #6
    Senior Member Leo Lima's Avatar
    Join Date
    Jul 2000
    Location
    São Paulo, Brazil
    Posts
    745
    Gosh, this is critical. You deselect everything and then select the symbol (MC in this case). Then you right click it and select Actions.
    Then paste the code.
    If you can't do this, I recommend the flash tutorial that comes with Flash. That's how I learn at flash 4...

    Regards,
    Leo Lima

  7. #7
    Member
    Join Date
    Jun 2000
    Posts
    93
    Thanks for the help, Leo. I need to bone up on THE ACTIONSCRIPTING OF FLASH 5. I cannot do any of what you are tell me. If they only didn't change the actionscripting that was flash 4.

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