我让字母表在屏幕上打开和关闭。我正在使用数组 SHIFT 来执行此操作以转到下一个字母。当我到达数组的最后一个元素,字母 Z 时,我怎样才能回到开头?
另一个例子是,如果您有一组图片,并且在您查看完最后一张图片后,代码将带您重新开始并从那里开始查看。
这是我需要将班次设置回零的代码。
var Letter:MovieClip;
function fl_MouseClickHandler_2(event:MouseEvent):void
{
if(Letter)
{
var gone:MovieClip = Letter as MovieClip;
TweenMax.to(Letter, 1, { x:0 , ease:Back.easeOut, onComplete:removeLetter});
function removeLetter(){
removeChild(gone);
}
}
if(Alphabet.length!=0)
{
Letter = new alphabetLetter();
addChild(Letter);
/// THIS KEY CODE LINE THAT USES SHIFT
Letter.letter.text = Alphabet.shift();
TweenMax.fromTo(Letter, 2, {x:stage.stageWidth}, {x:stage.stageWidth/2-Letter.width, ease:Expo.easeOut});
}
else
{
//// TRIED THIS BUT DOES NOT WORK
Alphabet.unshift(27);
}
/// WHAT CODE DO I USE HERE TO SET THE ARRAY BACK TO THE BEGINNING?
if(Alphabet.length==0)
{
Alphabet.shift = 0; /// ???
}