原本是希望可以弄一個”丟一個路徑字串近來傳回XML”的CLASS
可是XML又不給繼承@@
只好作一個專門處理justgroup.xml的CLASS
解讀XML時是用像ex.PBgroup.group[j].ch;的方式
所以我還以為可以用ex.PBgroup.group.length找到他的長度(數量)
結果是不行的
所以只好在內再加一個num自己記錄
不過後來想想其實不用這麼麻煩的還寫到ARRAY中
直接用XML排也OK不是嗎?
恩 真的要用到再來改吧
想睡了 = =
package com.justV2.dao { import com.justV2.vo.*; import com.justV2.util.ModelLocator; import flash.display.*; import flash.events.*; import flash.net.*; import flash.utils.*; public class LoadGroupXML extends Sprite { public var loader:URLLoader = new URLLoader(); private var model:ModelLocator = ModelLocator.getInstance(); public function LoadGroupXML() { loader.addEventListener(Event.COMPLETE,handleComplete); loader.load(new URLRequest(model.weburl+"justgroup.xml") ); } private function handleComplete(event:Event):void{ try{ var ex:XML = new XML( loader.data ); for(var i:int=0;iex.Bgroup.@num);i++){ var g1:Jgroup = new Jgroup(); g1.name_tw = ex.Bgroup.group[i].ch; g1.name_en = ex.Bgroup.group[i].en; model.PBgroup_arr[i] = g1; } for(var j:int=0;jex.PBgroup.@num);j++){ var g2:Jgroup = new Jgroup(); g2.name_tw = ex.PBgroup.group[j].ch; g2.name_en = ex.PBgroup.group[j].en; model.PBgroup_arr[j] = g2; } for(var k:int=0;kex.Fgroup.@num);k++){ var g3:Jgroup = new Jgroup(); g3.name_tw = ex.Fgroup.group[k].ch; g3.name_en = ex.Fgroup.group[k].en; model.Fgroup_arr[k] = g3; } //trace(model.Bgroup_arr,model.PBgroup_arr,model.Fgroup_arr) }catch(e:TypeError){ trace(e.message); } } } } |