Copy link to clipboard
Copied
Hello! Can you help me to find my mistake in code? Bottoms don't correctly work always and images shows inconsistently. Thank you.
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
var arrayX:Array = [0,-600,-1200];
var currentIndex:Number = 0;
left_mc.addEventListener(MouseEvent.CLICK,navigate);
right_mc.addEventListener(MouseEvent.CLICK,navigate);
left_mc.buttonMode = true;
right_mc.buttonMode = true;
function navigate(e:MouseEvent):void
{
if (e.currentTarget == left_mc)
{
currentIndex--;
checkArrows();
var stw1:Tween = new Tween(content_mc,"x",Back.easeOut,arrayX[currentIndex],arrayX[currentIndex - 1],4,true);
}
else
{
currentIndex++;
var stw:Tween = new Tween(content_mc,"x",Back.easeOut,arrayX[currentIndex - 1],arrayX[currentIndex],4,true);
checkArrows();
}
}
function checkArrows():void
{
if (currentIndex == 0)
{
left_mc.visible = false;
}
else if (currentIndex == arrayX.length - 1)
{
right_mc.visible = false;
}
else
{
left_mc.visible = true;
right_mc.visible = true;
}
}
the first problem i see is the tweens are local to a function so they are eligible to be gc'd before they complete. the second is you need to call checkArrows() when you start:
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
var arrayX:Array = [0,-600,-1200];
var currentIndex:Number = 0;
left_mc.addEventListener(MouseEvent.CLICK,navigate);
right_mc.addEventListener(MouseEvent.CLICK,navigate);
left_mc.buttonMode = true;
right_mc.buttonMode = true;
checkArrows;
var stw:Tween;
function n
...Copy link to clipboard
Copied
the first problem i see is the tweens are local to a function so they are eligible to be gc'd before they complete. the second is you need to call checkArrows() when you start:
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
var arrayX:Array = [0,-600,-1200];
var currentIndex:Number = 0;
left_mc.addEventListener(MouseEvent.CLICK,navigate);
right_mc.addEventListener(MouseEvent.CLICK,navigate);
left_mc.buttonMode = true;
right_mc.buttonMode = true;
checkArrows;
var stw:Tween;
function navigate(e:MouseEvent):void
{
if (e.currentTarget == left_mc)
{
currentIndex--;
checkArrows();
stw = new Tween(content_mc,"x",Back.easeOut,arrayX[currentIndex],arrayX[current Index - 1],4,true);
}
else
{
currentIndex++;
stw= new Tween(content_mc,"x",Back.easeOut,arrayX[currentIndex - 1],arrayX[currentIndex],4,true);
checkArrows();
}
}
function checkArrows():void
{
if (currentIndex == 0)
{
left_mc.visible = false;
}
else if (currentIndex == arrayX.length - 1)
{
right_mc.visible = false;
}
else
{
left_mc.visible = true;
right_mc.visible = true;
}
}
Copy link to clipboard
Copied
Thank you so much!
Copy link to clipboard
Copied
you're welcome.