Webmaster

Flash : Creating a dialog box
Contents ]
David Einhorn

Moving Limitations

If you test the animation in its current state, you will notice that the window may quit the stage and partially disappear. To solve this problem, we will define a virtual rectangle that will limit the window movements. For this, we will need to slightly modify our script:

  1. Open the window object.

  2. Select the Drag & Drop button and display its different actions (Modify > Instance, Actions tab).

  3. Select the second line of the script (Start Drag).

  4. In the right-hand part of the window, tick the Constrain to rectangle checkbox.

  5. Enter the values that will enable you to restrict the window displacement to the stage boundaries in each of the four fields (Left, Top, Right, Bottom). These values define the position of the four sides of the rectangle.



  6. Figure 4: Defining the constraining rectangle

These values depend on the dimensions of your graphic elements, the size of your stage, and the rotation (or registration) point of your symbol (by default, in the centre).In short, these coordinates must correspond to the limits of your object's rotation point movements. Don't forget to subtract (or add) the dimensions of your window to this value.

Moving the rotation point Position the symbol's rotation point in the upper left-hand corner of the window. You can then easily define the constraining rectangle. If you specify 0 in the Top and Left fields, the window will position itself in the upper corner of the stage.

Our Drag & Drop is now finished and cannot extend beyond the scene boundaries anymore. But let's go on playing for a while. We will continue to imitate the behaviour of the operating system windows.



  1   2   3   4