5 Replies Latest reply on Jun 27, 2007 10:20 PM by ajayscript

    Creating Boundary on the stage

    ajayscript Level 1
      Hi Guys,

      I m facing problem regarding defining boundary on the stage . I have lots of dynamic images on the screen through xml file and theay all are draggable on the stage but some times it dragged out side of the movie or scene , sfter seeing it in the html page it looks like out of the bounday means out of the stage , because i have lots of buttons on the stage as similar width and height of the screen or stage. So please suggest me how can i efine boundary to the tage to prevent all the draggable items to out side of the stage.

      Please help me out.
        • 1. Re: Creating Boundary on the stage
          Level 7
          ajayscript,

          > So please suggest me how can i efine boundary to the
          > tage to prevent all the draggable items to out side of the
          > stage.

          How are you causing your objects to be dragged? Are you using
          MovieClip.startDrag() (AS2) or Sprite.startDrag() (AS3)? If so, either one
          of those gives you the option to provide a constraining boundary, which you
          can set to be whatever you like.

          If, instead, you're updating the position of the movie clip in some sort
          of loop -- (setInterval() (AS2), perhaps, or the Timer class (AS3) -- you
          could use an if() statement to check the movie clip's position against a
          pre-determined set of coordinates.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: Creating Boundary on the stage
            ajayscript Level 1
            i am using AS2 but there is lots of dynamic movie clips and lots of buttons on the stage . Buttons are similar size of the stage on which drag script is running.
            • 3. Re: Creating Boundary on the stage
              MurMeeKeer Level 1
              Keep a mask over the stage and do your work in the masked layer.
              • 4. Re: Creating Boundary on the stage
                Level 7
                ajayscript,

                >> i am using AS2 but there is lots of dynamic movie
                >> clips and lots of buttons on the stage .

                This wouldn't make a difference (not that I can see). Each of your
                dynamic movie clips has a reference, which makes each one available to
                ActionScript. As you cause each to be draggable, use the optional parameter
                in the startDrag() method to set a boundary. The Stage class will give you
                the Stage's width and height (see "Stage class" in the ActionScript 2.0
                Language Reference) and you can perform math on the numbers, if necessary.


                David Stiller
                Adobe Community Expert
                Dev blog, http://www.quip.net/blog/
                "Luck is the residue of good design."


                • 5. Creating Boundary on the stage
                  ajayscript Level 1
                  Keep a mask over the stage and do your work in the masked layer.


                  Mask is not working in our case , i have masked all layers on the stage but there is no masking affect still dragging out side of the stage