javascript - Loop through vector in as3 to left and to right -
O people, I'm stuck here ... I have a vector with 6 elements. All the elements are hidden and if I showed it then the element is same on position 3:
for (var i: int = 0; i
All good, but ... I've added events for two arrows (left and right):
leftArrow.addEventListener (MouseEvent.CLICK , GoLeft); RightArrow.addEventListener (MouseEvent.CLICK, goRight); The GoLeft and goRight functions require the element in position 3 and if I show the random array [3]-1 to the random array [1] and the random array [3] from the random array 1 + [5] . I need to tell that my array has been altered !!! I have tried:
Personal function goRight (e: MouseEvent): zero {for (var i: int = 0; i & lt; 6; i ++) {randomizedexchange [i] .alpha = 0; } Var toRight: number = 3; ToRight ++; Detection (toRight); Random word [toRight] .alpha = 1; }
I know that the coR is not good every time the goRight function is added to var is set to true 3 :(.
Once again, if I was not clear .. I got the Shell array, I hide all the elements and touch the element displayed from the array on position 3 and I am left to parse 2 arrows through the array and start with the array [3] What I try to achieve is left and right. Thx :)
you have some other variables that track the goLeft and goRight position, to separate all the alpha to a different function Should make Every time your go left or gate function is called, it should target it, index should be top or bottom.
var leftPosition: int; Var correct post: int; Var Center: int; // If you want the position of your center to be dynamic var randomly, then it can be used: array; Var items Looking for: Sprite; in this(); Private work init () {centerPosition = 3; // If you switch to some dynamic right then change this number Position = centerPosition + 1; LeftPosition = centerPostion - 1; LeftArrow.addEventListener (MouseEvent.CLICK, goLeft); RightArrow.addEventListener (MouseEvent.CLICK, goRight); ItemLookingFor = Random Text [centerPosition]; ZeroAlphas (); } Private function ZeroAlpha (): Zero {for (var i: int = 0; i & lt; randomizedTexts.length; i ++) {random text [i] .alpha = 0; }} Private function goRight (e: MouseEvent): zero {if (rightPosition & lt; randomizedTexts.length -1) {random text [rightPosition ++] Alpha = 1; }} Personal function goLeft (e: MouseEvent): zero {if (leftPosition> 0) {random words [leftPosition -] Alpha = 1; }}
Comments
Post a Comment