Last active
December 21, 2015 01:38
-
-
Save wilsonsilva/6229241 to your computer and use it in GitHub Desktop.
This code is meant to answer Paulinatc's question http://www.portugal-a-programar.pt/topic/61213-botoes-de-controle-para-movieclipe-as3/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aRebobinar:Boolean = false; | |
botaoesquerda.addEventListener(MouseEvent.CLICK, animar); | |
botaodireita.addEventListener(MouseEvent.CLICK, retroceder); | |
mcinvi.addEventListener(MouseEvent.ROLL_OVER, parar); | |
mcinvi.addEventListener(MouseEvent.ROLL_OUT, tocar); | |
mcinvi.buttonMode = true; | |
function parar(event:MouseEvent) | |
{ | |
mcinvi.removeEventListener(Event.ENTER_FRAME, retrocederQuadroAQuadro); | |
mcinvi.stop(); | |
} | |
function tocar(event:MouseEvent) | |
{ | |
if (aRebobinar) { | |
retroceder(null); | |
} else { | |
mcinvi.play(); | |
} | |
} | |
function animar(event:MouseEvent):void | |
{ | |
mcinvi.removeEventListener(Event.ENTER_FRAME, retrocederQuadroAQuadro); | |
mcinvi.play(); | |
aRebobinar = false; | |
} | |
function retroceder(event:MouseEvent):void | |
{ | |
if (!mcinvi.hasEventListener(Event.ENTER_FRAME)) | |
{ | |
mcinvi.addEventListener(Event.ENTER_FRAME, retrocederQuadroAQuadro); | |
aRebobinar = true; | |
} | |
} | |
function retrocederQuadroAQuadro(event:Event):void | |
{ | |
if (mcinvi.currentFrame == 1) | |
{ | |
mcinvi.gotoAndStop(mcinvi.totalFrames); | |
} | |
else | |
{ | |
mcinvi.prevFrame(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment