0
我有字母上下屏幕。我正在使用數組SHIFT來做到這一點去下一個字母。當我到達數組的最後一個元素時,字母Z,我該如何去開始?as3 ARRAY SHIFT - 數組的末尾現在是什麼?
另一個例子是,如果你有圖片的數組,並查看完最後一前一後的代碼將再次帶你到開始時,你從那裏開始觀看。
這裏是我需要將位移設置回零的代碼。
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; /// ???
}
真棒的想法和感謝清理什麼「轉變」。 – 2013-05-13 19:15:40