1 2 Previous Next 73 Replies Latest reply on Aug 25, 2006 11:24 AM by Newsgroup_User

    Constrain To Sprite doesn't like rotating sprites...

    Level 7
      I have a bunch of movable sprites that I'd like to constrain to a box
      (basically just the whole stage). Problem is that they also have the
      ability to rotate, only at 90 degree intervals, though. They're relatively
      rectangular shapes (puzzle pieces). But when you rotate them with the
      Constrain to Sprite behavior on them, their aspect ratio gets all screwed
      up, and then sometimes they start moving on their own until they hit an
      edge, quite odd behavior. Is there a way to make this behavior work with
      sprites that can be rotated without these glitches? Or is there a better
      alternative? I tried writing my own contstrain script, which worked except
      that you could still drag the sprites off the edge, they'd just keep
      bouncing back and forth until you released the mouse button. Also not good
      behavior.


        • 1. Re: Constrain To Sprite doesn't like rotating sprites...
          Level 7
          Are you dragging these sprites around or are you moving them in some
          other way?

          If you are dragging the sprites around then you can use
          sprite(X).within(Y) to keep your sprites from leaving the stage area.

          1. Make a borderless empty toolbox shape sprite that is slightly smaller
          than the whole stage. Make is sprite 1.
          2. constrain each sprite to that sprite.
          3. use a simple behavior like this to control the moving of each sprite:

          ----------------
          property thisSprite
          property animateMe

          on beginSprite me
          thisSprite = me.spriteNum
          animateMe = false
          sprite(thisSprite).constraint = 1
          end

          on mouseDown me
          animateMe = true
          end

          on mouseUp me
          animateMe = false
          end

          on exitFrame me
          if animateMe then
          sprite(thisSprite).loc = the mouseLoc
          end if
          end
          ---------------

          --
          Rob
          _______
          Rob Dillon
          Adobe Community Expert
          http://www.ddg-designs.com
          412-243-9119

          http://www.macromedia.com/software/trial/
          • 2. Re: Constrain To Sprite doesn't like rotating sprites...
            Level 7
            > Are you dragging these sprites around or are you moving them in some
            > other way?

            They're being dragged around by the mouse. (Actually a touch-screen, but
            that doesn't change things much.) As for your behavior, it looks like this
            will make the sprites snap back onto the stage on mouseUp, but it won't
            prevent people from dragging them out of the stage to begin with. It's
            similar to my first attempt in that respect. So far, only the default
            Constrain behavior in Director has actually prevented me from dragging them
            off the stage, but given the way it behaves with rotations, it's completely
            unusable in this case.


            • 3. Re: Constrain To Sprite doesn't like rotating sprites...
              Level 7
              Have you tried it?

              --
              Rob
              _______
              Rob Dillon
              Adobe Community Expert
              http://www.ddg-designs.com
              412-243-9119

              http://www.macromedia.com/software/trial/
              • 4. Re: Constrain To Sprite doesn't like rotating sprites...
                Level 7
                > Have you tried it?

                Well, I had to alter it, because I want you to be able to grab the sprite
                from anywhere, and have the part you grabbed stay under the mouse. It's
                better, but you can still drag sprites half-way off the screen.

                The code I added went something like this:

                on mouseDown me
                me.grabPoint = the mouseLoc - sprite(thisSprite).loc
                end

                and:

                if animate then
                sprite(thisSprite).loc = the mouseLoc - me.grabPoint
                end if

                Any way to make sure the sprites always stay 100% on the screen? The
                Constrain to Sprite behavior does it somehow, despite its other flaws.


                • 5. Re: Constrain To Sprite doesn't like rotating sprites...
                  Level 7
                  I got part of the way there by adding this:

                  on enterFrame me
                  if thisSprite.right > 805 then thisSprite.locH = thisSprite.locH -
                  (thisSprite.right-800)
                  if thisSprite.left < -5 then thisSprite.locH = thisSprite.locH -
                  (thisSprite.left)
                  if thisSprite.bottom > 605 then thisSprite.locV = thisSprite.locV -
                  (thisSprite.bottom-600)
                  if thisSprite.top < -5 then thisSprite.locV = thisSprite.locV -
                  (thisSprite.top)
                  end

                  (Stage is always 800x600, I allowed for 5 pixel bleed on the edges.) This
                  behavior is what I was using the first time before I tried the Constrain to
                  Sprite. I had to put this on the enterFrame, not the exitFrame, because on
                  the exitFrame, it will keep jumping back and forth every frame, which is
                  bad. What happens now is you can drag it half-way off the stage, but when
                  you release the mouse, it snaps back to the edge. I'd rather not be allowed
                  to drag it off in the first place, but this is definitely an improvement.
                  Only problem is sometimes when you rotate a piece such that it goes off the
                  edge, it will do the snap, and no longer be under the mouse. But that's
                  livable.


                  • 6. Re: Constrain To Sprite doesn't like rotating sprites...
                    Level 7
                    What you have to do is to make the constrainer sprite smaller than the
                    stage size. The constraint method is looking a the registration point of
                    the sprite that you are dragging. For a bitmap, this is at it's center.
                    So, at a minimum, you want that constrainer to be inside the stage by at
                    least half the width of the sprite that you are dragging.

                    --
                    Rob
                    _______
                    Rob Dillon
                    Adobe Community Expert
                    http://www.ddg-designs.com
                    412-243-9119

                    http://www.macromedia.com/software/trial/
                    • 7. Re: Constrain To Sprite doesn't like rotating sprites...
                      Level 7
                      What you have to do is to make the constrainer sprite smaller than the
                      stage size. The constraint method is looking a the registration point of
                      the sprite that you are dragging. For a bitmap, this is at it's center.
                      So, at a minimum, you want that constrainer to be inside the stage by at
                      least half the width of the sprite that you are dragging.

                      --
                      Rob
                      _______
                      Rob Dillon
                      Adobe Community Expert
                      http://www.ddg-designs.com
                      412-243-9119

                      http://www.macromedia.com/software/trial/
                      • 8. Re: Constrain To Sprite doesn't like rotating sprites...
                        Level 7
                        > What you have to do is to make the constrainer sprite smaller than the
                        > stage size. The constraint method is looking a the registration point of
                        > the sprite that you are dragging. For a bitmap, this is at it's center.
                        > So, at a minimum, you want that constrainer to be inside the stage by at
                        > least half the width of the sprite that you are dragging.

                        Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                        same size and shape, and there can be as many as 100 of them. Plus, when
                        they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                        4:3) Unless I had a seperate constrainer for every single piece, or altered
                        the constrainer depending on what piece you were moving... Actually, that
                        might just work, I'd have to change the rect of the constrainer on
                        mouseDown, keeping it exactly half the sprite's width from the sides and
                        half the height from the top and bottom. Only problem is when a sprite is
                        rotated 90 or 270 degrees, the height is actually the width and vice versa,
                        so I'd have to account for that, too... Do-able, but sounds like it's more
                        complex that it needs to be. Unless you know a simpler way...


                        • 9. Re: Constrain To Sprite doesn't like rotating sprites...
                          Level 7
                          What you have to do is to make the constrainer sprite smaller than the
                          stage size. The constraint method is looking a the registration point of
                          the sprite that you are dragging. For a bitmap, this is at it's center.
                          So, at a minimum, you want that constrainer to be inside the stage by at
                          least half the width of the sprite that you are dragging.

                          --
                          Rob
                          _______
                          Rob Dillon
                          Adobe Community Expert
                          http://www.ddg-designs.com
                          412-243-9119

                          http://www.macromedia.com/software/trial/
                          • 10. Re: Constrain To Sprite doesn't like rotating sprites...
                            Level 7
                            > What you have to do is to make the constrainer sprite smaller than the
                            > stage size. The constraint method is looking a the registration point of
                            > the sprite that you are dragging. For a bitmap, this is at it's center.
                            > So, at a minimum, you want that constrainer to be inside the stage by at
                            > least half the width of the sprite that you are dragging.

                            Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                            same size and shape, and there can be as many as 100 of them. Plus, when
                            they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                            4:3) Unless I had a seperate constrainer for every single piece, or altered
                            the constrainer depending on what piece you were moving... Actually, that
                            might just work, I'd have to change the rect of the constrainer on
                            mouseDown, keeping it exactly half the sprite's width from the sides and
                            half the height from the top and bottom. Only problem is when a sprite is
                            rotated 90 or 270 degrees, the height is actually the width and vice versa,
                            so I'd have to account for that, too... Do-able, but sounds like it's more
                            complex that it needs to be. Unless you know a simpler way...


                            • 11. Re: Constrain To Sprite doesn't like rotating sprites...
                              Level 7
                              What you have to do is to make the constrainer sprite smaller than the
                              stage size. The constraint method is looking a the registration point of
                              the sprite that you are dragging. For a bitmap, this is at it's center.
                              So, at a minimum, you want that constrainer to be inside the stage by at
                              least half the width of the sprite that you are dragging.

                              --
                              Rob
                              _______
                              Rob Dillon
                              Adobe Community Expert
                              http://www.ddg-designs.com
                              412-243-9119

                              http://www.macromedia.com/software/trial/
                              • 12. Re: Constrain To Sprite doesn't like rotating sprites...
                                Level 7
                                > What you have to do is to make the constrainer sprite smaller than the
                                > stage size. The constraint method is looking a the registration point of
                                > the sprite that you are dragging. For a bitmap, this is at it's center.
                                > So, at a minimum, you want that constrainer to be inside the stage by at
                                > least half the width of the sprite that you are dragging.

                                Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                same size and shape, and there can be as many as 100 of them. Plus, when
                                they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                4:3) Unless I had a seperate constrainer for every single piece, or altered
                                the constrainer depending on what piece you were moving... Actually, that
                                might just work, I'd have to change the rect of the constrainer on
                                mouseDown, keeping it exactly half the sprite's width from the sides and
                                half the height from the top and bottom. Only problem is when a sprite is
                                rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                so I'd have to account for that, too... Do-able, but sounds like it's more
                                complex that it needs to be. Unless you know a simpler way...


                                • 13. Re: Constrain To Sprite doesn't like rotating sprites...
                                  Level 7
                                  Well, it works pretty well. It's still a little weird when you rotate a
                                  piece near the edge, but this is probably the best it's going to get.
                                  Thanks.


                                  • 14. Re: Constrain To Sprite doesn't like rotating sprites...
                                    Level 7
                                    What you have to do is to make the constrainer sprite smaller than the
                                    stage size. The constraint method is looking a the registration point of
                                    the sprite that you are dragging. For a bitmap, this is at it's center.
                                    So, at a minimum, you want that constrainer to be inside the stage by at
                                    least half the width of the sprite that you are dragging.

                                    --
                                    Rob
                                    _______
                                    Rob Dillon
                                    Adobe Community Expert
                                    http://www.ddg-designs.com
                                    412-243-9119

                                    http://www.macromedia.com/software/trial/
                                    • 15. Re: Constrain To Sprite doesn't like rotating sprites...
                                      Level 7
                                      > What you have to do is to make the constrainer sprite smaller than the
                                      > stage size. The constraint method is looking a the registration point of
                                      > the sprite that you are dragging. For a bitmap, this is at it's center.
                                      > So, at a minimum, you want that constrainer to be inside the stage by at
                                      > least half the width of the sprite that you are dragging.

                                      Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                      same size and shape, and there can be as many as 100 of them. Plus, when
                                      they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                      4:3) Unless I had a seperate constrainer for every single piece, or altered
                                      the constrainer depending on what piece you were moving... Actually, that
                                      might just work, I'd have to change the rect of the constrainer on
                                      mouseDown, keeping it exactly half the sprite's width from the sides and
                                      half the height from the top and bottom. Only problem is when a sprite is
                                      rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                      so I'd have to account for that, too... Do-able, but sounds like it's more
                                      complex that it needs to be. Unless you know a simpler way...


                                      • 16. Re: Constrain To Sprite doesn't like rotating sprites...
                                        Level 7
                                        Well, it works pretty well. It's still a little weird when you rotate a
                                        piece near the edge, but this is probably the best it's going to get.
                                        Thanks.


                                        • 17. Re: Constrain To Sprite doesn't like rotating sprites...
                                          Level 7
                                          What you have to do is to make the constrainer sprite smaller than the
                                          stage size. The constraint method is looking a the registration point of
                                          the sprite that you are dragging. For a bitmap, this is at it's center.
                                          So, at a minimum, you want that constrainer to be inside the stage by at
                                          least half the width of the sprite that you are dragging.

                                          --
                                          Rob
                                          _______
                                          Rob Dillon
                                          Adobe Community Expert
                                          http://www.ddg-designs.com
                                          412-243-9119

                                          http://www.macromedia.com/software/trial/
                                          • 18. Re: Constrain To Sprite doesn't like rotating sprites...
                                            Level 7
                                            > What you have to do is to make the constrainer sprite smaller than the
                                            > stage size. The constraint method is looking a the registration point of
                                            > the sprite that you are dragging. For a bitmap, this is at it's center.
                                            > So, at a minimum, you want that constrainer to be inside the stage by at
                                            > least half the width of the sprite that you are dragging.

                                            Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                            same size and shape, and there can be as many as 100 of them. Plus, when
                                            they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                            4:3) Unless I had a seperate constrainer for every single piece, or altered
                                            the constrainer depending on what piece you were moving... Actually, that
                                            might just work, I'd have to change the rect of the constrainer on
                                            mouseDown, keeping it exactly half the sprite's width from the sides and
                                            half the height from the top and bottom. Only problem is when a sprite is
                                            rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                            so I'd have to account for that, too... Do-able, but sounds like it's more
                                            complex that it needs to be. Unless you know a simpler way...


                                            • 19. Re: Constrain To Sprite doesn't like rotating sprites...
                                              Level 7
                                              Well, it works pretty well. It's still a little weird when you rotate a
                                              piece near the edge, but this is probably the best it's going to get.
                                              Thanks.


                                              • 20. Re: Constrain To Sprite doesn't like rotating sprites...
                                                Level 7
                                                What you have to do is to make the constrainer sprite smaller than the
                                                stage size. The constraint method is looking a the registration point of
                                                the sprite that you are dragging. For a bitmap, this is at it's center.
                                                So, at a minimum, you want that constrainer to be inside the stage by at
                                                least half the width of the sprite that you are dragging.

                                                --
                                                Rob
                                                _______
                                                Rob Dillon
                                                Adobe Community Expert
                                                http://www.ddg-designs.com
                                                412-243-9119

                                                http://www.macromedia.com/software/trial/
                                                • 21. Re: Constrain To Sprite doesn't like rotating sprites...
                                                  Level 7
                                                  > What you have to do is to make the constrainer sprite smaller than the
                                                  > stage size. The constraint method is looking a the registration point of
                                                  > the sprite that you are dragging. For a bitmap, this is at it's center.
                                                  > So, at a minimum, you want that constrainer to be inside the stage by at
                                                  > least half the width of the sprite that you are dragging.

                                                  Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                                  same size and shape, and there can be as many as 100 of them. Plus, when
                                                  they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                                  4:3) Unless I had a seperate constrainer for every single piece, or altered
                                                  the constrainer depending on what piece you were moving... Actually, that
                                                  might just work, I'd have to change the rect of the constrainer on
                                                  mouseDown, keeping it exactly half the sprite's width from the sides and
                                                  half the height from the top and bottom. Only problem is when a sprite is
                                                  rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                                  so I'd have to account for that, too... Do-able, but sounds like it's more
                                                  complex that it needs to be. Unless you know a simpler way...


                                                  • 22. Re: Constrain To Sprite doesn't like rotating sprites...
                                                    Level 7
                                                    Well, it works pretty well. It's still a little weird when you rotate a
                                                    piece near the edge, but this is probably the best it's going to get.
                                                    Thanks.


                                                    • 23. Re: Constrain To Sprite doesn't like rotating sprites...
                                                      Level 7
                                                      What you have to do is to make the constrainer sprite smaller than the
                                                      stage size. The constraint method is looking a the registration point of
                                                      the sprite that you are dragging. For a bitmap, this is at it's center.
                                                      So, at a minimum, you want that constrainer to be inside the stage by at
                                                      least half the width of the sprite that you are dragging.

                                                      --
                                                      Rob
                                                      _______
                                                      Rob Dillon
                                                      Adobe Community Expert
                                                      http://www.ddg-designs.com
                                                      412-243-9119

                                                      http://www.macromedia.com/software/trial/
                                                      • 24. Re: Constrain To Sprite doesn't like rotating sprites...
                                                        Level 7
                                                        > What you have to do is to make the constrainer sprite smaller than the
                                                        > stage size. The constraint method is looking a the registration point of
                                                        > the sprite that you are dragging. For a bitmap, this is at it's center.
                                                        > So, at a minimum, you want that constrainer to be inside the stage by at
                                                        > least half the width of the sprite that you are dragging.

                                                        Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                                        same size and shape, and there can be as many as 100 of them. Plus, when
                                                        they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                                        4:3) Unless I had a seperate constrainer for every single piece, or altered
                                                        the constrainer depending on what piece you were moving... Actually, that
                                                        might just work, I'd have to change the rect of the constrainer on
                                                        mouseDown, keeping it exactly half the sprite's width from the sides and
                                                        half the height from the top and bottom. Only problem is when a sprite is
                                                        rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                                        so I'd have to account for that, too... Do-able, but sounds like it's more
                                                        complex that it needs to be. Unless you know a simpler way...


                                                        • 25. Re: Constrain To Sprite doesn't like rotating sprites...
                                                          Level 7
                                                          Well, it works pretty well. It's still a little weird when you rotate a
                                                          piece near the edge, but this is probably the best it's going to get.
                                                          Thanks.


                                                          • 26. Re: Constrain To Sprite doesn't like rotating sprites...
                                                            Level 7
                                                            What you have to do is to make the constrainer sprite smaller than the
                                                            stage size. The constraint method is looking a the registration point of
                                                            the sprite that you are dragging. For a bitmap, this is at it's center.
                                                            So, at a minimum, you want that constrainer to be inside the stage by at
                                                            least half the width of the sprite that you are dragging.

                                                            --
                                                            Rob
                                                            _______
                                                            Rob Dillon
                                                            Adobe Community Expert
                                                            http://www.ddg-designs.com
                                                            412-243-9119

                                                            http://www.macromedia.com/software/trial/
                                                            • 27. Re: Constrain To Sprite doesn't like rotating sprites...
                                                              Level 7
                                                              > What you have to do is to make the constrainer sprite smaller than the
                                                              > stage size. The constraint method is looking a the registration point of
                                                              > the sprite that you are dragging. For a bitmap, this is at it's center.
                                                              > So, at a minimum, you want that constrainer to be inside the stage by at
                                                              > least half the width of the sprite that you are dragging.

                                                              Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                                              same size and shape, and there can be as many as 100 of them. Plus, when
                                                              they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                                              4:3) Unless I had a seperate constrainer for every single piece, or altered
                                                              the constrainer depending on what piece you were moving... Actually, that
                                                              might just work, I'd have to change the rect of the constrainer on
                                                              mouseDown, keeping it exactly half the sprite's width from the sides and
                                                              half the height from the top and bottom. Only problem is when a sprite is
                                                              rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                                              so I'd have to account for that, too... Do-able, but sounds like it's more
                                                              complex that it needs to be. Unless you know a simpler way...


                                                              • 28. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                Level 7
                                                                Well, it works pretty well. It's still a little weird when you rotate a
                                                                piece near the edge, but this is probably the best it's going to get.
                                                                Thanks.


                                                                • 29. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                  Level 7
                                                                  What you have to do is to make the constrainer sprite smaller than the
                                                                  stage size. The constraint method is looking a the registration point of
                                                                  the sprite that you are dragging. For a bitmap, this is at it's center.
                                                                  So, at a minimum, you want that constrainer to be inside the stage by at
                                                                  least half the width of the sprite that you are dragging.

                                                                  --
                                                                  Rob
                                                                  _______
                                                                  Rob Dillon
                                                                  Adobe Community Expert
                                                                  http://www.ddg-designs.com
                                                                  412-243-9119

                                                                  http://www.macromedia.com/software/trial/
                                                                  • 30. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                    Level 7
                                                                    > What you have to do is to make the constrainer sprite smaller than the
                                                                    > stage size. The constraint method is looking a the registration point of
                                                                    > the sprite that you are dragging. For a bitmap, this is at it's center.
                                                                    > So, at a minimum, you want that constrainer to be inside the stage by at
                                                                    > least half the width of the sprite that you are dragging.

                                                                    Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                                                    same size and shape, and there can be as many as 100 of them. Plus, when
                                                                    they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                                                    4:3) Unless I had a seperate constrainer for every single piece, or altered
                                                                    the constrainer depending on what piece you were moving... Actually, that
                                                                    might just work, I'd have to change the rect of the constrainer on
                                                                    mouseDown, keeping it exactly half the sprite's width from the sides and
                                                                    half the height from the top and bottom. Only problem is when a sprite is
                                                                    rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                                                    so I'd have to account for that, too... Do-able, but sounds like it's more
                                                                    complex that it needs to be. Unless you know a simpler way...


                                                                    • 31. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                      Level 7
                                                                      Well, it works pretty well. It's still a little weird when you rotate a
                                                                      piece near the edge, but this is probably the best it's going to get.
                                                                      Thanks.


                                                                      • 32. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                        Level 7
                                                                        What you have to do is to make the constrainer sprite smaller than the
                                                                        stage size. The constraint method is looking a the registration point of
                                                                        the sprite that you are dragging. For a bitmap, this is at it's center.
                                                                        So, at a minimum, you want that constrainer to be inside the stage by at
                                                                        least half the width of the sprite that you are dragging.

                                                                        --
                                                                        Rob
                                                                        _______
                                                                        Rob Dillon
                                                                        Adobe Community Expert
                                                                        http://www.ddg-designs.com
                                                                        412-243-9119

                                                                        http://www.macromedia.com/software/trial/
                                                                        • 33. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                          Level 7
                                                                          > What you have to do is to make the constrainer sprite smaller than the
                                                                          > stage size. The constraint method is looking a the registration point of
                                                                          > the sprite that you are dragging. For a bitmap, this is at it's center.
                                                                          > So, at a minimum, you want that constrainer to be inside the stage by at
                                                                          > least half the width of the sprite that you are dragging.

                                                                          Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                                                          same size and shape, and there can be as many as 100 of them. Plus, when
                                                                          they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                                                          4:3) Unless I had a seperate constrainer for every single piece, or altered
                                                                          the constrainer depending on what piece you were moving... Actually, that
                                                                          might just work, I'd have to change the rect of the constrainer on
                                                                          mouseDown, keeping it exactly half the sprite's width from the sides and
                                                                          half the height from the top and bottom. Only problem is when a sprite is
                                                                          rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                                                          so I'd have to account for that, too... Do-able, but sounds like it's more
                                                                          complex that it needs to be. Unless you know a simpler way...


                                                                          • 34. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                            Level 7
                                                                            Well, it works pretty well. It's still a little weird when you rotate a
                                                                            piece near the edge, but this is probably the best it's going to get.
                                                                            Thanks.


                                                                            • 35. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                              Level 7
                                                                              What you have to do is to make the constrainer sprite smaller than the
                                                                              stage size. The constraint method is looking a the registration point of
                                                                              the sprite that you are dragging. For a bitmap, this is at it's center.
                                                                              So, at a minimum, you want that constrainer to be inside the stage by at
                                                                              least half the width of the sprite that you are dragging.

                                                                              --
                                                                              Rob
                                                                              _______
                                                                              Rob Dillon
                                                                              Adobe Community Expert
                                                                              http://www.ddg-designs.com
                                                                              412-243-9119

                                                                              http://www.macromedia.com/software/trial/
                                                                              • 36. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                                Level 7
                                                                                > What you have to do is to make the constrainer sprite smaller than the
                                                                                > stage size. The constraint method is looking a the registration point of
                                                                                > the sprite that you are dragging. For a bitmap, this is at it's center.
                                                                                > So, at a minimum, you want that constrainer to be inside the stage by at
                                                                                > least half the width of the sprite that you are dragging.

                                                                                Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                                                                same size and shape, and there can be as many as 100 of them. Plus, when
                                                                                they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                                                                4:3) Unless I had a seperate constrainer for every single piece, or altered
                                                                                the constrainer depending on what piece you were moving... Actually, that
                                                                                might just work, I'd have to change the rect of the constrainer on
                                                                                mouseDown, keeping it exactly half the sprite's width from the sides and
                                                                                half the height from the top and bottom. Only problem is when a sprite is
                                                                                rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                                                                so I'd have to account for that, too... Do-able, but sounds like it's more
                                                                                complex that it needs to be. Unless you know a simpler way...


                                                                                • 37. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                                  Level 7
                                                                                  Well, it works pretty well. It's still a little weird when you rotate a
                                                                                  piece near the edge, but this is probably the best it's going to get.
                                                                                  Thanks.


                                                                                  • 38. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                                    Level 7
                                                                                    What you have to do is to make the constrainer sprite smaller than the
                                                                                    stage size. The constraint method is looking a the registration point of
                                                                                    the sprite that you are dragging. For a bitmap, this is at it's center.
                                                                                    So, at a minimum, you want that constrainer to be inside the stage by at
                                                                                    least half the width of the sprite that you are dragging.

                                                                                    --
                                                                                    Rob
                                                                                    _______
                                                                                    Rob Dillon
                                                                                    Adobe Community Expert
                                                                                    http://www.ddg-designs.com
                                                                                    412-243-9119

                                                                                    http://www.macromedia.com/software/trial/
                                                                                    • 39. Re: Constrain To Sprite doesn't like rotating sprites...
                                                                                      Level 7
                                                                                      > What you have to do is to make the constrainer sprite smaller than the
                                                                                      > stage size. The constraint method is looking a the registration point of
                                                                                      > the sprite that you are dragging. For a bitmap, this is at it's center.
                                                                                      > So, at a minimum, you want that constrainer to be inside the stage by at
                                                                                      > least half the width of the sprite that you are dragging.

                                                                                      Yeah, I was kind of seeing that - problem is that the pieces aren't all the
                                                                                      same size and shape, and there can be as many as 100 of them. Plus, when
                                                                                      they rotate 90 degrees, their aspect ratio is reversed. (e.g.: 3:4 becomes
                                                                                      4:3) Unless I had a seperate constrainer for every single piece, or altered
                                                                                      the constrainer depending on what piece you were moving... Actually, that
                                                                                      might just work, I'd have to change the rect of the constrainer on
                                                                                      mouseDown, keeping it exactly half the sprite's width from the sides and
                                                                                      half the height from the top and bottom. Only problem is when a sprite is
                                                                                      rotated 90 or 270 degrees, the height is actually the width and vice versa,
                                                                                      so I'd have to account for that, too... Do-able, but sounds like it's more
                                                                                      complex that it needs to be. Unless you know a simpler way...


                                                                                      1 2 Previous Next