How to Center a Video Object Relative to the Stage

If you want to center a video object in a Flash movie so it stays centered even when the movie area dimensions change, you can create a dynamic object alignment using just a few lines of ActionScript code. By converting an imported movie clip into a video object, you can manipulate the video controls and alignment using ActionScript, the scripting language used to control Flash elements. The dynamic object alignment code works by using the Flash movie width and height values to determine the video object placement.

Instructions

    • 1

      Launch Flash.

    • 2

      Click "File" and "Open." Click to select a Flash movie file on your computer, then click "Open."

    • 3

      Click to select the video object that you want to center.

    • 4

      Type "movie_obj" as the instance name in the "Properties" window.

    • 5

      Click the "Insert Layer" button at the bottom of the timeline pane.

    • 6

      Type "Actions" as the new layer.

    • 7

      Click to select the first frame of the "Actions" layer in the timeline, then press "F9" to open the actions panel.

    • 8

      Type "movie_obj.x=movie_obj.stage.stageWidth/2-movie_obj.width/2;" and press "Enter." This line of ActionScript code centers the video object horizontally on the stage.

    • 9

      Type "movie_obj.y=movie_obj.stage.stageHeight/2-movie_obj.height/2;" and press "Enter" to center the video object vertically on the stage.

    • 10

      Click "File" and "Save."

Related Searches:

References

Comments

Related Ads

Featured