从 PHP 加载到 AIR 应用程序时,在不同位置显示文本


display text in different position when loading from a php to AIR app

我有一个包含多行"title"的数据库。

我要求我的 AS3 代码像这样加载这些行:

urlReqSearchAll.method = URLRequestMethod.POST;  
loader5.load(urlReqSearchAll);
loader5.addEventListener(Event.COMPLETE,complete);
}
function complete(e:Event):void {
 addChild(list);
   products = JSON.parse(loader5.data) as Array;
     products.reverse();
    for(var i:int = 0; i < products.length; i++){
        createListItem(i, products[i]);
}
function showList():void {
    list.visible = true;
    searchList.visible = false;
}
function createListItem(index:int, item:Object):void {
    var listItem:TextField = new TextField();
    var myFormat:TextFormat = new TextFormat();
    myFormat.size = 25
    myFormat.color = 0x000000;
    myFormat.font = "Mohave";
    listItem.defaultTextFormat = myFormat;
    listItem.text = item.title;
    listItem.x = 2;
    listItem.y = 75+ index * 40;
    listItem.width = 350;
    listItem.height = 80;
 listItem.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
        showDetails(item);
    });
    list.addChild(listItem);
    str = item.title;
}

该列表是在我的文本字段中创建的 listItem 。但事情是这样的:

item1
item2
item3
..

可以这样显示吗?

item1                          item2                         item3
item4      

如果是这样,如何?

感谢

因此,假设您的"列表"是一个简单的影片剪辑,您可以执行以下操作

您必须声明 x 和 y,然后根据索引更新它们并分配给列表项。 例如:

var sx:Number = 0;
var sy:Number = 0;
var hgap:Number = 200;
var vgap:Number = 40;

然后在您的创建列表项方法中

if( index%3 == 0 && index>0 )
{
    sx = 0;
    sy = sy+vgap;
}
else
{
    sx = sx + hgap
}
listItem.x = sx;
listItem.y = sy;

希望这有帮助。