これを説明する方法がわかりませんが、このコードが正しい画像とアイコン ファイルをプルしないのはなぜですか? 35 行目で間違った情報を引き出し続けているため、他のすべてのデータが 1 ノード遅れています。以下の 3 つの場所を削除しても、xml が間違っています。なぜこれを行うのでしょうか?
xml データを検証し、すべてのファイルが正しいフォルダーにあることを確認しました。
たとえば、これはトレースの結果です。
pm#: 35 xmlnodename: Causey's Pharmacy iconFL: http://www.mysite.com/folder1/folder2/media/marker.png imgFL: http://www.mysite.com/folder1/folder2/media/century21_img.swf
pm#: 36 xmlnodename: Century 21 Property Shoppe iconFL: http://www.mysite.com/folder1/folder2/media/century21_icon.gif imgFL: http://www.mysite.com/folder1/folder2/media/century21_img.swf
pm#: 37 xmlnodename: Century 21 Property Shoppe iconFL: http://www.mysite.com/folder1/folder2/media/century21_icon.gif imgFL: http://www.mysite.com/folder1/folder2/media/type1.swf
これが私のxmlの34〜36行目です
<location>
<name>Bobby's Pharmacy</name>
<street>123 Steet St.</street>
<city>SomeCity</city>
<state>ZZ</state>
<zip>12345</zip>
<lat>45.7520099</lat>
<long>-80.0816701</long>
<iconFile>marker.png</iconFile>
<imageFile>type1.swf</imageFile>
<motion>no</motion>
<featured>no</featured>
<category>none</category>
</location>
<location>
<name>Century 21 Property Shoppe</name>
<street>456 SomeOther St</street>
<city>SomeCity</city>
<state>ZZ</state>
<zip>12345</zip>
<lat>45.5683603</lat>
<long>-80.483271</long>
<iconFile>century21_icon.gif</iconFile>
<imageFile>century21_img.swf</imageFile>
<motion>no</motion>
<featured>yes</featured>
<category>none</category>
</location>
<location>
<name>Century 21 Property Shoppe</name>
<street>none</street>
<city>none</city>
<state>none</state>
<zip>none</zip>
<lat>45.4949689</lat>
<long>-80.6597955</long>
<iconFile>century21_icon.gif</iconFile>
<imageFile>century21_img.swf</imageFile>
<motion>no</motion>
<featured>yes</featured>
<category>none</category>
</location>
ここに私のフレックスコードがあります:
private var mediaLoc:String = "http://www.mysite.com/folder1/folder2/media/";
public function addMarkers():void
{
var dict:Object = new Object();
var i:Number = 0;
var e:Number = locXML..location.length()+1;
trace("add markers: " + locXML..location.length());
for(i;i<e;i++){
if (locXML.location.name[i.toString()]== "mapLogo"){
trace(i + " logo");
//get lat and long from xml
dict["locPointMarker_lat" + i.toString()] = locXML.location.lat[i.toString()];
dict["locPointMarker_long" + i.toString()] = locXML.location.long[i.toString()];
//get iconfile name from xml and append it to mediaLoc--filepath
dict["iconFileLink" + i.toString()] = mediaLoc + locXML.location.iconFile[i.toString()];
//create a new url request using the dict["iconFileLink" + i.toString()] filepath
dict["iconFileReq" + i.toString()] = new URLRequest(dict["iconFileLink"+i.toString()]);
//create a new pointmarker for the map
dict["locPointMarker"+i.toString()] = new PointMarker();
//apply buttonmode and handcursor to the new pointmarker
dict["locPointMarker"+i.toString()].buttonMode = dict["locPointMarker"+i.toString()].useHandCursor = true;
//create a loader to load the icon file
dict["icon"+i.toString()] = new Loader();
//load the icon file
dict["icon"+i.toString()].load(dict["iconFileReq"+i.toString()], context);
//put the marker on the map
_map.putMarker(new Location(locXML.location.lat[i.toString()], locXML.location.long[i.toString()]), dict["locPointMarker"+i.toString()]);
trace("pm#: " + i + " xmlnodename: " + locXML.location.name[i.toString()] + " iconFL: " + dict["iconFileLink" + i.toString()] + " imgFL: " + dict["imageFileLink" + i.toString()]);
dict["locPointMarker"+i.toString()].mouseChildren=false;
}else{
//the following else does the same thing except it also adds the image file
dict["locPointMarker_lat" + i.toString()] = locXML.location.lat[i.toString()];
dict["locPointMarker_long" + i.toString()] = locXML.location.long[i.toString()];
dict["iconFileLink" + i.toString()] = mediaLoc + locXML.location.iconFile[i.toString()];
dict["iconFileReq" + i.toString()] = new URLRequest(dict["iconFileLink"+i.toString()]);
dict["locPointMarker"+i.toString()] = new PointMarker();
dict["locPointMarker"+i.toString()].buttonMode = dict["locPointMarker"+i.toString()].useHandCursor = true;
dict["icon"+i.toString()] = new Loader();
dict["icon"+i.toString()].load(dict["iconFileReq"+i.toString()], context);
dict["icon"+i.toString()].x = -iconHeight/2;
dict["icon"+i.toString()].y = -iconWidth/2;
_map.putMarker(new Location(locXML.location.lat[i.toString()], locXML.location.long[i.toString()]), dict["locPointMarker"+i.toString()]);
trace("pm#: " + i + " xmlnodename: " + locXML.location.name[i.toString()] + " iconFL: " + dict["iconFileLink" + i.toString()] + " imgFL: " + dict["imageFileLink" + i.toString()]);
dict["locPointMarker"+i.toString()].mouseChildren=false;
}
}
}