Return to Kroll Design home page

Flash Tutorials (with .FLA files included)

 
« Return

ActionScript 3

Using a movieclip as a button

You can use either a button object or a movie clip as a button. Button objects are handy in that they have a specially designed timeline, with 'up', 'over', 'down' and 'hit' frames, but movie clips in general are more versatile than buttons, so this example shows how to use a movie clip as a button.

Download the FLA file

circle_mc.buttonMode = true; // change arrow cursor to finger
circle_mc.addEventListener(MouseEvent.MOUSE_OVER,mouseOver);
circle_mc.addEventListener(MouseEvent.MOUSE_OUT,mouseOut);
circle_mc.addEventListener(MouseEvent.CLICK,buttonClick);

const slowRotation = 10;
const fastRotation = 15;
var rotationSpeed:uint = slowRotation;
circle_mc.addEventListener(Event.ENTER_FRAME,rotateCircle);

myText_txt.text = "Click the rotating movie clip";

function rotateCircle(myEvent:Event)
{
	circle_mc.rotation += rotationSpeed;
}

function mouseOver(event:MouseEvent):void 
{
rotationSpeed = fastRotation;	
circle_mc.scaleX = circle_mc.scaleY = 1.1;
}

function mouseOut(event:MouseEvent):void
{
rotationSpeed = slowRotation;		
circle_mc.scaleX = circle_mc.scaleY = 1;
myText_txt.text = "Click the rotating movie clip";
}

function buttonClick(event:MouseEvent):void
{
myText_txt.text = "Movie clip button was clicked";
}


 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM