A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Mouse click and drag

  1. #1
    Member
    Join Date
    Nov 2006
    Posts
    41

    Mouse click and drag

    Hello friends,

    I have a question. I have an object that I would like user’s to be able to click on and move. As the object is moved it will generate numbers.

    The part I need help with is how to make the object movable by users. Kind of a mouse click and drag operation. The object is only going to move along the X axis.

    If anyone has an idea how I can do this, I would be very grateful for the assistance. Many thanks in advance for your help and your time.

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Member
    Join Date
    Nov 2006
    Posts
    41
    Hi Kortex,

    Many thanks for the links!

  4. #4
    Member
    Join Date
    Nov 2006
    Posts
    41
    Hi Friends,

    I found the following script for my FLASH issue... on (press) {
    startDrag("");
    }
    on (release) {
    stopDrag();
    }

    however, can anyone tell me is there a way I can restrict the movement of my object? For instance I only want the object to drag/move on the X axis.

    Many thanks for any advice you can offer.

  5. #5
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    The option parameters left , top , right , bottom Values relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip. These parameters are optional.

    So you would set the limit on the y movement to make sure that it only moves along the x axis.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  6. #6
    Member
    Join Date
    Nov 2006
    Posts
    41
    Hi Jeremy,

    Many thanks got it now..!
    So that others can benefit... please see script...
    on (press) {
    startDrag("", true, 0, 85, 400, 85);
    }
    on (release) {
    stopDrag();
    }

    On the following values... startDrag("", true, 0, 85, 400, 85);
    0 was for the Left - 85 was for the top, 400 was for the Right & 85 was for the Bottom setting.
    I learned that the number representing the Top and Bottom have to be the same in order to keep the movie in the exact centre of the project. For some reason FLASH Professional 8 doesn't use 'Y' as the Y axis, they use Top and Bottom.

    Thanks again Jeremy, I really appreciate your help and your time! Hopfully this info can also help others.

  7. #7
    Member
    Join Date
    Nov 2006
    Posts
    41
    Hi Friends,

    In my FLASH movie, it features a small object which the user can click and drag. Its working great thanks to Jeremys help.
    What I like to know is, is it possible to have text appear at various places as the object moves accross?

    For instance, when the object reaches 1/4 of the way along I need some text to say something, likewise at 1/2 and 3/4's of the the way.

    Many thanks in advance for any suggestions you may have.

  8. #8
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Well I would probably put an onEnterFrame event on the clip being dragged that detects its position and then fire of functions that display and remove the text based on the position of the clip. If that makes sense.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  9. #9
    Member
    Join Date
    Nov 2006
    Posts
    41
    Hi Jeremy,

    Many thanks for your help, I do appreciate it. Scripting is not my strong suit, but I am trying to learn it. Your discription of what I should try went way over my head, but I do appreciate your help very much. Thank you again!

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