Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 Actionscript 3中从左到右的方向_Actionscript 3_Animation - Fatal编程技术网

Actionscript 3 Actionscript 3中从左到右的方向

Actionscript 3 Actionscript 3中从左到右的方向,actionscript-3,animation,Actionscript 3,Animation,我想让我的盒子动画从左到右,现在我的盒子从上到下显示,我如何改变我的移动方向从左到右的盒子,我有九个盒子和三个相互线,如下图所示 这是我目前的代码 function random_item() { var listItem:Array = new Array(); for (var i:uint=0; i<15; i++) { listItem.push(i); } ItemLeft = 0; for (var x:uint

我想让我的盒子动画从左到右,现在我的盒子从上到下显示,我如何改变我的移动方向从左到右的盒子,我有九个盒子和三个相互线,如下图所示

这是我目前的代码

function random_item()
{
    var listItem:Array = new Array();
    for (var i:uint=0; i<15; i++)
    {
        listItem.push(i);
    }
    ItemLeft = 0;
    for (var x:uint=0; x<boardWidth; x++)
    {
        for (var y:uint=0; y<boardHeight; y++)
        {
            var thisItem:FirstBox = new FirstBox();
            thisItem.stop();
            thisItem.x = x * IcardHorizontalSpacing + IboardOffsetX;
            thisItem.y = y * IcardVerticalSpacing + IboardOffsetY;
            var r:uint = Math.floor(Math.random() * listItem.length);
            thisItem.cardface = listItem[r];
            listItem.splice(r,1);
            thisItem.addEventListener(MouseEvent.CLICK,clickItem);
            thisItem.buttonMode = true;
            addChild(thisItem);
            ItemLeft++;
        }
    }

}
函数随机项()
{
var listItem:Array=new Array();

for(var i:uint=0;i由于嵌套的
for
循环的y位置嵌套在x位置内,因此每个x位置将显示三个y位置(顶部、中部和底部)

通过如下所示构建
for
循环,切换变量顺序,您可能能够修复所看到的行为:

for (var y:uint=0; y<boardHeight; y++)
{
    for (var x:uint=0; x<boardWidth; x++)
    {
        //Inner code remains the same
    }
}
for(变量y:uint=0;y
//更改
对于(变量y:uint=0;y0;y--)
不过,在代码中,y循环嵌套在x循环中。
这意味着对于X循环的每次迭代,框将从下到上
我不知道这是不是你要找的东西。

请更具体地描述您想要的内容。

您首先在x上循环,然后在y上循环。这意味着它将为每列添加3项。反转循环以使其为每行添加3项

function random_item()
{
    var listItem:Array = new Array();
    for (var i:uint=0; i<15; i++)
    {
        listItem.push(i);
    }
    ItemLeft = 0;
    for (var y:uint=0; y<boardHeight; y++)
    {
        for (var x:uint=0; x<boardWidth; x++)
        {
            var thisItem:FirstBox = new FirstBox();
            thisItem.stop();
            thisItem.x = x * IcardHorizontalSpacing + IboardOffsetX;
            thisItem.y = y * IcardVerticalSpacing + IboardOffsetY;
            var r:uint = Math.floor(Math.random() * listItem.length);
            thisItem.cardface = listItem[r];
            listItem.splice(r,1);
            thisItem.addEventListener(MouseEvent.CLICK,clickItem);
            thisItem.buttonMode = true;
            addChild(thisItem);
            ItemLeft++;
        }
    }

}
函数随机项()
{
var listItem:Array=new Array();

对于(var i:uint=0;那里没有动画代码,所以很难判断出哪里出了问题。但是要创建一个从左到右的动画,只需增加
此项的x坐标即可。创建动画的一个非常简单的方法是使用TweenMax:是的,我的意思是,我已经更改了代码,它只适用于最前面的三个框顶部(从左到右)但另一个框没有消失(没有出现)我试过,但它似乎像第一个一样工作,方向仍然是从左上到左下
function random_item()
{
    var listItem:Array = new Array();
    for (var i:uint=0; i<15; i++)
    {
        listItem.push(i);
    }
    ItemLeft = 0;
    for (var y:uint=0; y<boardHeight; y++)
    {
        for (var x:uint=0; x<boardWidth; x++)
        {
            var thisItem:FirstBox = new FirstBox();
            thisItem.stop();
            thisItem.x = x * IcardHorizontalSpacing + IboardOffsetX;
            thisItem.y = y * IcardVerticalSpacing + IboardOffsetY;
            var r:uint = Math.floor(Math.random() * listItem.length);
            thisItem.cardface = listItem[r];
            listItem.splice(r,1);
            thisItem.addEventListener(MouseEvent.CLICK,clickItem);
            thisItem.buttonMode = true;
            addChild(thisItem);
            ItemLeft++;
        }
    }

}