Skip to content

Instantly share code, notes, and snippets.

@wilsonsilva
Last active December 21, 2015 01:38
Show Gist options
  • Save wilsonsilva/6229241 to your computer and use it in GitHub Desktop.
Save wilsonsilva/6229241 to your computer and use it in GitHub Desktop.
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