Hello All,
Thanks in advance for your help.
I am trying to send a value from one of my xml nodes (<marker>) by declaring it in a function ‘showData’ as a variable ‘XMLMarker’. If I trace this value (XMLmarker) it returns the right data found in the node <marker> (which is ‘myMarker_mc’). However, I need to tell the stage that myMarker_mc is a MovieClip…please see the ‘PROBLEM’ stated in the code below.
stop();
var placesXML:XML =
<places>
<place name= "Yogyakarta">
<frame>62</frame>
<Data>This is a delightful place in Java</Data>
<marker>myMarker_mc</marker>
</place>
<place name= "Banda_Aceh">
<frame>64</frame>
<Data>This is a delightful place in Northern Sumatra</Data>
<marker>myMarker_mc</marker>
</place>
and so on....
<place name= "Gili_isles">
<frame>78</frame>
<Data>This is a delightful place in Singapore</Data>
<marker>myMarker_mc</marker>
</place>
</places>
var nameBtn:Array = [Yogyakarta, Banda_Aceh, Bengkulu, Singapore_City, Dili, Jakarta, Taipei, Manila, Hanoi, Vientiane, Phnom_penh, Napyidaw, Bangkok, Kuala_lumpar, Bandar_seri_sagawan, solo, Gili_isles];
var i:int = nameBtn.length;
while(i){
i--;
nameBtn*.addEventListener(MouseEvent.CLICK, showData);
}
*//The above part all works well...*
function showData(e:MouseEvent):void{
var xmlFrame:int = placesXML.*.(@name == e.currentTarget.name).frame; *//works fine*
var xmlMarker:XMLList = placesXML.*.(@name == e.currentTarget.name).marker; *//This returns myMarker_mc - perfect! *
var XMLmarkers:String = xmlMarker.toString();*//This also returns myMarker_mc, except now its a String - great! *
var xmlData:XMLList = placesXML.*.(@name == e.currentTarget.name).Data; *//works fine*
gotoAndStop(xmlFrame);//This works perfectly.
XMLmarkers.myText.htmlText = xmlData.toString();*//PROBLEM - Now when the XMLmarkers variable is traced, it no longer shows 'myMarker_mc'. (What is shown is in the Code box further down this post)This line should activate the MovieClip (currently called 'myMarker_mc' on the stage). Within this movieclip there is a Dynamic textfield (called 'myText') and the text to go within this textfield comes from the variable (xmlData). *
}
You may ask, why do you want a variable to hold the value in the node , when that value is identical for each node, ie. it is always ‘myMarker_mc’, so why not just directly declare the variable ‘xmlMark’ as myMarker_mc. The reason is; the value in some of the nodes will soon be changing to ‘myMarker_mc2’ - a slightly different movieClip which I may need to call depending upon which place @name is chosen.
This is the new output thrown up by the variable XMLmarkers
<marker>
myMarker_mc
<myText>
<htmlText><p align="center"><font size="4"><font color="#CBB9AB"><b>INDONESIA</b><font color="#000000"> ……………. </p><br><br><font color="#6259DF"><p align="left"><font size="2"><b>ABOUT</b><br><font color="#000000">……………………….......<br><br><font color="#6259DF"><b>ATTRACTIONS</b><br><font color="#000000">Most travellers either spend their precious time elsewhere, or use this town for it’s transport connections.<br><br><font color="#6259DF"><b>TRANSPORT</b><br><font color="#161672"><i>Air: </i><font color="#000000">There is no airport here.<br><br><font color="#161672"><i>Road: </i><font color="#000000"> where (Type, Duration, Cost), where (Type, Duration, Cost)<br><br><font color="#161672"><i>Train: </i><font color="#000000">There is no station here.<br><br><font color="#4DFF00"><b>Sponsored Links</b><br><font color="#000000"><a href="http://www.offsoon.com/advertise"><u><i>Advertise</i></u></a> with us<br><br><font color="#6259DF"><b>Further Information</b><br><font color="#000000"><a href="http://www.bbc.co.uk/weather/world/country_guides/results.shtml?tt=TT002320">Click <u>here</u> to visit the BBC’s Weather page for Indonesia</a><br><br><a href="http://www.fco.gov.uk/en/travelling-and-living-overseas/travel-advice-by-country/asia-oceania/indonesia1"><u>FCO</u> – Click for British Nationals travel requirements</a><br><br><a href="http://www.who.int/countries/idn/en/"><u>World Health Organisation</u> – Click for news on Indonesia</a><br><br><a href="http://offsoon.com "> <u> Off Soon.com Home Page…</u></a><br><br><font color="#FD2424"><b>Notes</b><br><font color="#000000"> Different areas present different risks, but travellers should remain vigilant within tourist-populated areas, as these have traditionally presented themselves as targets to Terrorist Groups.<br><br> Petty Crime such as pick-pocketing, or theft does exist and tourists remain particularly vulnerable upon public transport, whilst walking backstreets alone, and especially if high value items are displayed.<br><br> Travellers should also be aware of localised political situations as violence has occasionally followed rallies and demonstrations.<br><br> Travellers should also be aware of Muslim practices and be careful not to cause offence whilst visiting different parts of Indonesia – this is particularly prevalent during the month of Ramadan. <br><br> If you plan on Driving in Indonesia, please obtain a valid international Driving Licence. <br><br> Due to Indonesia’s geographical position, the area is particularly susceptible to flash flooding, earthquakes and volcanic activity – this often results in impassable transport routes. <br><br><font color="#6259DF"><a ef="http//:offsoon.com/disclaimer"><u><b>Disclaimer</b></u></a></p></htmlText>
</myText>
</marker>
Bizarre…
Please help!