A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: constraining a drag?.....what am i doing wrong?

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    ok, i have a trapezoid shape,

    i also have a MC that i need to be able to drag around, within this trapezoid. my code is on the MC, its something like this.

    Code:
    onClipEvent (mouseDown) {
        startDrag ("", true);
    }
    onClipEvent (mouseUp) {
        stopDrag ();
        if (this.hitTest(_root.zone)) {
            stopDrag ();
        }
    }
    'zone' is the shape outside the trapezoid, that i want to contain the MC.
    its not happening, what am i doing wrong, is this even possible???....im probably just being stupid, can anyone help me?

    Tom

  2. #2
    Senior Member
    Join Date
    Mar 2001
    Posts
    527
    You can constrain a drag within the "startDrag()" option

    constrain it to a rectangle area

    fairly easy to set

    hope this helps

    gilesb

  3. #3
    NerdInside's Avatar
    Join Date
    May 2001
    Location
    Penguin Island
    Posts
    3,439
    For the trapezoid shape, add these actions:

    onClipEvent(mouseOver) {
    what_is_bing_dragged.stopDrag();
    }

    Change what_is_bing_dragged to the instance of what is being dragged.

    Might work, might not.

  4. #4
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    gilesB - i know about the constraining to a square, but i need to constrain it to a trapezoid.

    NerdInside- on clIpinside(mouseover) isnt a real handler. so i tried this.....

    i put this code on the MC -
    Code:
    onClipEvent (mouseDown) {
        startDrag ("", true);
    }
    onClipEvent (mouseUp) {
        stopDrag ();
        if (this.hitTest(_root.zone)) {
            stopDrag ();
        }
    }

    and i put this on the trapezoid MC

    Code:
    onClipEvent (enterFrame) {
        if (_root.rock.hitTest._root.zone) {
            stopDrag ();
        }
    }
    nothing....absoulutley nothing....what am i doing....

    ....

  5. #5
    NerdInside's Avatar
    Join Date
    May 2001
    Location
    Penguin Island
    Posts
    3,439
    Put this on the trapezoid MC:

    onClipEvent (mouseMove) {
    what_is_bing_dragged.stopDrag();
    }

    Sorry.

  6. #6
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    no,
    still doesn't work......

    baffled...

  7. #7
    NerdInside's Avatar
    Join Date
    May 2001
    Location
    Penguin Island
    Posts
    3,439
    onClipEvent (mouseDown) {
    startDrag ("", true);
    }
    onClipEvent (mouseUp) {
    stopDrag ();
    }
    onClipEvent (mouseMove) {
    if (this.hitTest(_root.zone)) {
    stopDrag ();
    }
    }

    How about that?

  8. #8
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    mmmmm...kinda works.

    but not quite.

    its really jerky, don't think it likes the code.
    if you drag it, it doesn't go into the shape, but if you click inside the shape, it appears inside the shape.

    check it out.
    http://<br /> <a rel="nofollow" hre....swf</a><br />


  9. #9
    NerdInside's Avatar
    Join Date
    May 2001
    Location
    Penguin Island
    Posts
    3,439
    It is using hitTest so it will use the code once it hits the movie clip, not whats inside the movie clip (anywhere the MC is, not just what the MC is displaying). Or as is to my understanding.

  10. #10
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    mmm. im confused.

    i know it supposed to stop when it hits the MC, thats what i want. but still..its not working.

    check out this swf..
    http://www30.brinkster.com/mallrat68/test.swf


    or the .fla is here
    http://www30.brinkster.com/mallrat68/test.fla


    ?????
    am i missing something

  11. #11
    NerdInside's Avatar
    Join Date
    May 2001
    Location
    Penguin Island
    Posts
    3,439
    You have the dot inside the MC, so it is already hitting.

  12. #12
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    yes, but the first swf, where the dot was outside the MC, didn't work either, the drag worked, and the hitTest stopped the draggable MC entering the trapezoid, but if you clicked inside the trapezoid, the MC would enter it. also the draggable MC was really jerky.

  13. #13
    NerdInside's Avatar
    Join Date
    May 2001
    Location
    Penguin Island
    Posts
    3,439
    Thats because of the code. On mouseDown, start drag. That means on moseDown anywhere start the drag. Its better to convert it to a button, then use on(press) on(release) and you can still use the last code but place it on the MC of what you are hittesting.

  14. #14
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    ok so now, ive got this.

    on the draggable button, i have this.

    Code:
    on (press) {
        startDrag (this);
    }
    on (release) {
        stopDrag ();
    }
    and on the MC that i dont want it to enter, i have this
    Code:
    onClipEvent (mouseMove) {
        if (this.hitTest(_root.zone)) {
            stopDrag ();
        }
    }
    but it does nothing...doesn't even drag now....
    hmmm...confusing.

    (thanks for all this help by the way)


  15. #15
    NerdInside's Avatar
    Join Date
    May 2001
    Location
    Penguin Island
    Posts
    3,439
    You have to press on the button, and drag. It should work.

  16. #16
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    um...nope. am i missing something. does it work for you?

    could you check the swf, and the file

    http://<br /> <a rel="nofollow" hre....swf</a><br />

    http://<br /> <a rel="nofollow" hre....fla</a><br />


  17. #17
    NerdInside's Avatar
    Join Date
    May 2001
    Location
    Penguin Island
    Posts
    3,439
    I can't download your fla

    I have no idea what is going on.

  18. #18
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    "sob"

  19. #19
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    anyone.....please......

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