作者tabear (胖熊)
看板Flash
標題[問題] Loader 在迴圈中傳值的問題
時間Wed Oct 24 10:40:42 2012
我到DB抓資料存到obj裡面 (這邊確定OK)
然後要把資料呈現到畫面,但是load圖那一段 有錯誤(抓不到$i)
請問我要如何修改??
Source Code:
for($i:int=0;$i<obj.length;$i++){
var news_obj:Object=new Object;
news_obj.title=obj[$i].title;
news_obj.url=obj[$i].content;
news_obj.photo=null;
aTemp.push(news_obj);
var loadPic:Loader=new Loader;
var imageUrl:String="
http://XXXXXXX/img/"+obj[$i].name_img;
loadPic.contentLoaderInfo.addEventListener(Event.COMPLETE,
function(e:Event):void{
// trace(aTemp[$i].title);
aTemp[$i].photo = e.currentTarget.content;
});
loadPic.load(new URLRequest(imageUrl));
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.34.86.59
※ 編輯: tabear 來自: 114.34.86.59 (10/24 11:03)
1F:→ chengchieh:$i的資料型態沒定義? 10/24 11:43
程式碼是有定義的~~是我PO上來漏打
2F:→ chengchieh:在func中要透過loader的url去比對obj裡面的index 10/24 11:46
3F:→ chengchieh:才能得到$i 10/24 11:46
※ 編輯: tabear 來自: 114.34.86.59 (10/24 14:24)