Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default snapping

    hi
    I have a problem in my scripting in which i want to snap one model to the
    other.
    I have two model's sphere01 n sphere02.
    To move the model's i have used the `Drag Model Behaviour' and a `Mouse Left
    Trigger'.
    I want sphere01 to snap to sphere 02 when i drag it near to sphere02.
    The position of sphere01 is (vector(-140,37,95)) n after snapping i want it to
    be (vector(-46,0,0)).
    The script i have written is like this:

    property pSprite
    property pMember
    property pPosition

    on beginSprite me

    pSprite = sprite(me.spritenum)
    pMember = pSprite.member

    pPosition = pMember.model("sphere01").transform.position.loc

    end

    on mouseUp me
    if pPosition>=(vector(100,0,0)) and pPosition<=(vector(-10,0,0)) then

    put pPosition = (vector(-46,0,0))

    end if

    end

    PLz can someone solve my problem out.

    William





    WILLIE8768 Guest

  2. Similar Questions and Discussions

    1. tutorial file for snapping
      hi can some one plz help me with some tutorial file on snapping 3d objects in 3d world. william
    2. snapping flash components together
      I'm piecing together all these flash components and they aren't connecting the only gaps we are trying to fix are: 1. between bottom of black...
    3. Need help snapping...Please!
      Hi guys, a buddy and I have been trying to figure this one out - maybe someone out there has either done this or seen something similar. We're...
    4. Help Please :- Common Snapping Distance
      Hi all, I have a lot of sprites on stage which represent magnets. All these sprites have the same height but different widths. I want to write a...
    5. rectangular marquee tool snapping
      Richard, Thank you! I thought there must be a "snap to grid" button somewhere. Silly me - I looked for it under Edit>Preferences>Grid. Eric
  3. #2

    Default Re: snapping

    maybe you could use the vector object's distanceTo() method. i've not tried
    this modification of your code, but i think it or something like it will work.
    change SOME_FLOATING_POINT_NUMBER to be however close the two have to be
    together to trigger the snap. you'll probably have to experiment to see what
    you want it to be. let us know how it goes.

    property pSprite
    property pMember
    property pPositionS1
    property pPositionS2

    on beginSprite me

    pSprite = sprite(me.spritenum)
    pMember = pSprite.member

    pPositionS1 = pMember.model("sphere01").transform.position
    pPositionS2 = pMember.model("sphere02").transform.position

    end

    on mouseUp me

    if pPositionS1.distanceTo(pPositionS2) <= SOME_FLOATING_POINT_NUMBER then

    pMember.model("sphere01").transform.position = (vector(-46,0,0))

    end if

    end

    Ex Malterra Guest

  4. #3

    Default Snapping

    Hi,

    I'm realy new to Flex and gaining some experience at the moment. I wanted to
    make a programm where I can drag panels around and if I come close to an other
    panel they will snap to each other. (Like in Winamp or other programms)

    I know how dragging is done but how can I make the panels "snap" to each other?

    Flexism Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139