In previous my tutorial Drag and Drop a button in flash you would have seen how to make a button draggable and droppable. In this tutorial you will make a movie clip change its color by dragging and dropping a button on it. Nice to hear ! Follow the steps below to get like that.

Creating a movie clip:

  1. Create a movie clip with two frames.
  2. In the first frame, draw a building or anything you like in orange color and add the script ” stop(); ” to the first frame.
  3. In the second frame, change the color of the building from orange to pink and also add the script ” stop(); ” to the second frame
  4. Come out of the editing stage by clicking “scene 1”.
  5. Select the movie clip and give the “Instance name” to the movie clip as “buildings” in the properties window (shortcut key- Ctrl-F3).
  6. Below is a detailed image of the above words.

Creating two color brushes :

  1. Create a orange colored brush and convert it to a button. Again convert the button to a “movie clip“. Give the instance name to that movie clip as “orange
  2. Create a pink colored brush and convert it to a button. Again convert the button to a “movie clip”. Give the instance name to that movie clip as “pink
  3. The brush created by me is shown below.

Adding some scripts :

Add the following script to the orange colored brush (to the button and not to the movie clip).

 on (press) {

 startDrag("_root.orange");

 }

 on (release) {

 stopDrag();

 if (_root.orange._droptarget == "/buildings") {

 _root.buildings.gotoandStop(1);

 }

 }

Add the following script to the pink colored brush (to the button and not to the movie clip).

 on (press) {

 startDrag("_root.pink");

 }

 on (release) {

 stopDrag();

 if (_root.pink._droptarget == "/buildings") {

 _root.buildings.gotoandStop(2);

 }

 }

That’s all your work is over. Press Ctrl+Enter to test the movie.

Sample:

Add your comment 1 Comment so far

  • tj

    I think your tutorials are great. Plain and simple!!! I was trying to figure out how to do a coloring game. This has helped me tremendously. Thanks!