Download the Clicker.as class and save it in your project directory.
Download the ClickerClown project and save it in the same directory.
In the demo movie above several things are clickable, but only the hat and shoes in the file you downloaded.
Add frames to the flowers, pants, and jacket and make them Clickers also.
Study the code for the Clicker class. Make sure you undersatnad what each line does.
The code for the clicker class is shown below:
package {
import flash.display.MovieClip;
import flash.events.*;
public class Clicker extends MovieClip {
public function Clicker() {
this.stop(); //prevent it from cycling through all the frames
this.buttonMode=true; //show a hand
this.addEventListener(MouseEvent.CLICK, goClick); //listen for the click
}//constructor
private function goClick(e:MouseEvent):void {
if (currentFrame<totalFrames) { //not at the last frame
gotoAndStop(currentFrame+1); //go to the next frame
} else {
gotoAndStop(1); //go back to the first frame
}
}//goClick
}//class
}//package