从php加载到AIR应用程序时,在不同位置显示文本
我有一个有多行“标题”的数据库 我要求我的AS3代码像这样加载这些行:从php加载到AIR应用程序时,在不同位置显示文本,php,actionscript-3,air,Php,Actionscript 3,Air,我有一个有多行“标题”的数据库 我要求我的AS3代码像这样加载这些行: urlReqSearchAll.method = URLRequestMethod.POST; loader5.load(urlReqSearchAll); loader5.addEventListener(Event.COMPLETE,complete); } function complete(e:Event):void { addChild(list); products = JSON.parse(loa
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;
}
item1
item2
item3
..
可以这样显示吗
item1 item2 item3
item4
如果是,怎么做
Thx因此,假设您的“列表”是一个简单的电影剪辑,您可以执行以下操作
您必须声明x和y,然后根据索引更新它们并分配给列表项。例如:
var sx:Number = 0;
var sy:Number = 0;
var hgap:Number = 200;
var vgap:Number = 40;
然后在createListItem方法中
if( index%3 == 0 && index>0 )
{
sx = 0;
sy = sy+vgap;
}
else
{
sx = sx + hgap
}
listItem.x = sx;
listItem.y = sy;
希望这有帮助