Monday, April 20, 2009

AS3 using a MovieClip as a Button w/ Animation

LINK to explanation/TUTORIAL (http://www.actionscript.org/forums/showthread.php3?t=164295):
code using:
import flash.display.MovieClip
import flash.events.MouseEvent:

import flash.display.MovieClip; 

import flash.events.MouseEvent;

myMc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);

myMc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler); 

myMc.addEventListener(MouseEvent.CLICK, onClickHandler); 

myMc.addEventListener(MouseEvent.MOUSE_DOWN, onPressHandler); 

myMc.addEventListener(MouseEvent.MOUSE_UP, onReleaseHandler);

// if you want a hand cursor  

myMc.buttonMode = true; myMc.useHandCursor = true;


function onRollOverHandler(myEvent:MouseEvent) {

        trace("s1");  

        myMc.gotoAndPlay("_over"); 


function onRollOutHandler(myEvent:MouseEvent) {  

               trace("Out");  

               myMc.gotoAndPlay("_out");  

               // myMc.stop(); 

}


function onClickHandler(myEvent:MouseEvent) {  

              trace("I waited for Press AND Release!!!"); 


function onPressHandler(myEvent:MouseEvent) {  

              trace("Press"); 


function onReleaseHandler(myEvent:MouseEvent) {  

              trace("Release"); 

}

 













No comments:

Post a Comment