Pt4 - Scripting Action
We have named all out elements and set the properties of the placed blocks. Now it is time to script the buttons inside the '*_out' movie clips to initiate the drag'n'drop action when the button is pressed. When the mouse button is released, dropping the dragged block, we want to check where it was dropped. If it was dropped in the right slot on the box, we will then make it 'snap' into place.
- Select the 'circle_out' movie clip for editing. When possible it is helpful to use Flash's Edit in Place option for editing movie clips (option-double clicking the movie clip or control-click and select 'Edit in Place'). This may seem confusing at first as it allows you to edit the timelines of movie clips while they are on the main stage. If you find this confusing, then you can use the standard edit feature or edit movie clips in a new window.
- Double click the circle button to access the actions for the button.
- Click the plus (+) button from the Actions tab and select 'Drag Movie Clip.' Set the options of the drag movie clip as follows:
- Click the 'Start drag operation' radio button
- The target for the circle button is '/circle_out' - without the quotes.
- Click the 'Lock mouse to center' check box.
- Flash automatically sets all button actions to initiate on the release of the mouse button. To drag the movie clip while the button is pressed we will need to change the mouse event handler to initiate when the mouse button is pressed. Select the ActionScript line 'On(Release)' and change it to the 'On (Press)' handler by clicking the Press checkbox and deselecting the Release checkbox.
|» Level Intermediate|
Rating: 7 Votes: 48
|Information Architect - Multimedia Designer - Creative Guy|
|Download the files used in this tutorial.|
|Download (693 kb)|
|More help? Search our boards for quick answers!|