3 Replies Latest reply on May 31, 2014 9:49 AM by Rod@FOF

    Make simultaneously or sequentially moveable and editable fields or text sprites in movie.

    Rod@FOF Level 1

      I am having a bit of a problem with creating field or text sprites that are both editable and moveable. I want a user to be able to enter text into the sprites and move them around on the stage to serve as labels for schematics they are making. I can easily make them moveable or editable, but when trying to do both one property interferes with the other. I have been using various combinations of the properties on the mouseenter, mouseleave, and mousedown handlers. One version of my non-workable efforts are below. Seems I can move a sprite but once editable gets focus can't move it anymore.  Any ideas?

      rod

      ___________________________________________________________

      property spritenum

       

      on mouseenter me
        sprite(spritenum).moveablesprite = true

      sprite(spritenum).editable = false
      end
      on mouseleave me
        sprite(spritenum).editable = false
        sprite(spritenum).moveablesprite = false

      end 

       

      on mousedown me
        sprite(spritenum).moveablesprite = true
        sprite(spritenum).editable = false
      end

       

      on mouseup me
        sprite(spritenum).moveablesprite = false
        sprite(spritenum).editable = true
      end

        • 1. Re: Make simultaneously or sequentially moveable and editable fields or text sprites in movie.
          Rod@FOF Level 1

          Just a quick p.s. I have been able to achieve the desired action by using an if-then loop on the mousedown. But this is extremely confusing for the users who never know from one moment to the next if they are moving or inputting.

          ______________________________________________________________________________

          property spritenum

           

          on mouseenter me
            sprite(spritenum).moveablesprite = true
            sprite(spritenum).editable = false
          end

           

          on mouseleave me
            sprite(spritenum).editable = false
            sprite(spritenum).moveablesprite = false
           
          end

           

          on mousedown me
            if sprite(spritenum).moveablesprite = true then
             
              sprite(spritenum).moveablesprite = false
              sprite(spritenum).editable = true
            else
              sprite(spritenum).moveablesprite = true
              sprite(spritenum).editable = false
            end if
           
          end

          • 2. Re: Make simultaneously or sequentially moveable and editable fields or text sprites in movie.
            Ladnarth Level 1

            Just set your text properties in the property inspector and attach a drag sprite behavior.

             

            --  Drag sprite

             

            property  sp  -- this sprite

            property  pStartLoc  --  sprite location upon mouseDown

            property  pMouseStart  -- mouse location upon mouseDown

            property  pMoving  -- flag for enterFrame. True/False

             

             

            on beginSprite me

              sp = sprite(me.spriteNum)

              pMoving = false

            end beginSprite

             

             

            on mouseDown me

              pStartLoc = sp.loc

              pMouseStart = _mouse.mouseLoc

              pMoving = true

            end mouseDown

             

             

            on mouseUp me

              pMoving = false

            end

             

             

            on mouseUpoutside me

              pMoving = false

            end

             

             

            on enterFrame me

              if not pMoving then exit

             

              deltaMouse = _mouse.mouseLoc - pMouseStart

              sp.loc = pStartLoc + deltaMouse

            end enterFrame

            • 3. Re: Make simultaneously or sequentially moveable and editable fields or text sprites in movie.
              Rod@FOF Level 1

              Thank you for the solution. I like how you worked around the dilemma I faced by allowing the editability of the sprite to be controlled by the property manager leaving only the draggable issue for the mousedown handler. It works 99% well. Only problem is that while dragging some of the text becomes highlighted some of the time and it looks a bit cludgy. But certainly much better than where I started! Thanks again.

               

              Rod