我正在尝试使用某些按钮简单地生成数组的一部分。代码并没有真正正常工作。
代码如下:
import flash.events.MouseEvent;
var clock_01: Clock_one = new Clock_one ();
var clock_02: Clock_two = new Clock_two ();
var clock_03: Clock_three = new Clock_three ();
var clock_04: Clock_four = new Clock_four ();
var socket_one:socket;
var clock_x_position = 100;
var clock_y_position = 100;
var clock_Array: Array = new Array ();
clock_Array.push( clock_01,clock_02,clock_03,clock_04);
var clock_counter = 2;
var v = 0;
var c = 0;
clock_display();
function clock_display()
{
for (v; v < clock_counter; v++)
{
addChild(clock_Array[v]);
clock_Array[v].x = clock_x_position;
clock_Array[v].y = clock_y_position;
clock_y_position += 300;
trace( clock_Array [v]);
c = 0;
trace(v);
}
}
go_previous.addEventListener(MouseEvent.CLICK, go_back);
go_next.addEventListener(MouseEvent.CLICK, go_forward);
function go_back(l:MouseEvent)
{
v -= 2;
trace("The v after subtraction of 2" + v);
trace("Going Previous Function Starts ----------------");
for (v; v < clock_counter; v++)
{
removeChild(clock_Array[v]);
trace("The v after child removal" + v);
c++;
if (c == 2)
{
v -= 4;
trace("The v after subtraction in previous function is " + v);
clock_y_position = 100;
clock_counter -= 2;
trace("The clock counter in previous function is" + clock_counter);
clock_display();
}
}
}
function go_forward(l:MouseEvent)
{
v -= 2;
trace("Going Forwarf Function");
for (v; v < clock_counter; v++)
{
removeChild(clock_Array[v]);
trace("The v after subtraction in forward function is " + v);
trace("it atleast goes here");
c++;
if (c == 2)
{
v += 1;
clock_y_position = 100;
clock_counter += 2;
trace("The clock counter is" + clock_counter);
trace("The V is " +v);
clock_display();
}
}
}
在 go_back 函数下,v 并没有像需要的那样被实际减去 2。无论如何,这就是它在跟踪中显示的内容。有人可以帮我解决吗?