How to Disable a Movie Clip Button in AS3

Disabling a movie clip button provides you with more AS3 (Flash ActionScript 3) design capabilities. For example, using AS3 to disable a movie clip button lets you offer different versions of a flash game to your customers. Disabling a button can also let you prevent a game player from controlling game pieces when it's the other player's turn. Disabling a movie clip button requires just one line of AS3 code -- making it one of the easiest and fastest ways to change a Flash game's features and functions.

Things You'll Need

  • Adobe Flash Professional (CS3, CS4 or CS5 Versions)
Show More

Instructions

    • 1

      Start your Adobe Flash Professional program. Select "Open" from the File menu of the main Flash menu bar to locate the AS3 file in which the movie clip button you want to open is located. Click the AS3 file in the "File Open" dialog box that appears; click the "OK" button to load the file.

    • 2

      Click "Actions" from the "Window" option in the main Flash menu bar to display the ActionScript (AS3) program editor.

    • 3

      Locate the line in the ActionScript editor where you want the place the code to disable the movie clip button. Select a line position such that when you play your AS3 Flash movie, the button will be immediately disabled.

    • 4

      Identify the instance name that was assigned to the movie clip button that you want to disable. Click a button on the stage to display its instance name in the property inspector, if the button was created with Flash drawing tools. Use the "Find" feature in the ActionScript editor to locate button object declarations in the code, if the button was created with ActionScript AS3 code. Use "myMovieClipButton" as the instance name you want to disable for the movie clip button in the following example.

    • 5

      Identify what the myMovieClipButton does when it is clicked with your mouse; this way, when you test button disabling, you will know that the function it normally performs is disabled. Look at the addEventListener method that is attached to this movie clip button to determine what function the button calls when the button receives a mouse click (CLICK), when the mouse hovers over the button (OVER), when the mouse button is held down (DOWN) and when the mouse button is released when positioned over the button (UP).

    • 6

      Enter in the code to disable the movie clip button on the line in the Actions editor that you previously selected. Type in the command, "myMovieClipButton.mouseenabled = false," on this line to disable the myMovieClipButton.

    • 7

      Select the "Test Movie" option from the "Control" menu at the Flash main menu bar. Position your mouse cursor over the myMovieClipButton and click your mouse. Verify that the the original function of myMouseClipButton does not work when the mouse interacts with the button (such as when the mouse sends a CLICK, OVER, UP or DOWN event).

Learnify Hub © www.0685.com All Rights Reserved