flash actionscript:
So here is the deal. I am creating a flash map for texas. On this map it will show 20-30 icons representing various restaraunts. Flash will be getting this data from an XML document. This XML document will have latitude and longitude coordinates. I am trying to figure out a way to create an actionscript that will load the xml, and then place a movie clip(icon_mc) at that representative point on the vector map. Then when you rollover the icon, it would show the comments that were related to this icon. This does not have to be pinpoint exact, just approximate. The XML code will be similar to this code: <data> <restaraunt> <name>Mcdonalds</name> <latitude> 53? 10' S</latitude> <long>70? 54' W</long> <image>whatever.jpg</image> <comments>Blah Blah Blah.</comments> </restaraunt> <restaraunt> <name>BurgerKing</name> <latitude> 33? 1' N</latitude> <long>96? 6' W</long> <image>whatever.jpg</image> <comments>Blah Blah Blah.</comments> </restaraunt> </data> I can have this code layed out however I choose, so if its easier, it may work better to maybe make the lat and long individual, such as: <longitude> <degree>34?</degree> <number>10'</number> <direction>S</direction> </longitude> Any Ideas out there? I would be indebted to you for any help you may give. Thanks.
I'm thinking: <restaurant name="BurgerKing"> <location lat="34.16" long="96.1" /> <image src="somefile.jpg" /> <comments> <!]> </comments> </restaurant> I don't have a lot of experience with XML in Flash, but a bit. You are going to have to convert the lat/long from strings to numbers, so it would be easier to start with decimal and have a nice little function that will change it up. Also if you are just doing Texas it will always be North and West so that isn't needed and will make it more difficult. If you want to extend it to other parts of the world just have your little function change negative numbers into East and South. I recommend putting the comments in a CDATA wrapper. That way you can use html tags and all. In that case be sure to use nodeValue to get the text and to apply it to a field with myTextField.htmlText NOT myTextField.text.
Oh, and for the part that you actually asked about. Check out the help files for the XML class. But basically: myXML=new XML(); myXML.ignorewhite=true; myXML.onLoad=function(success){ if(success){ // //The happy pin in map putting code. // } else { trace("There was an error loading the XML.") } myXML.load(someXML.xml); For the "happy pin in map putting code" look at something like MovieClip.attachMovie().
Thanks for the help, but really the thing I was more interested in and what I really needed help with was the type of actionscript to actually take the lat and long numbers and somehow create a formula to place this relationally on the stage using X and Y coordinates. Basically lat =45 so that translates to X=450, long=23 so y=230...etc... Any ideas? Or even books you would recommend?
Don't see what you're looking for? Try a search.
|