472,133 Members | 1,039 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

Load images into flash map points via xml using .text equivalent??

elamberdor
Hi All!

Well, i'm modifying a dynamic map, with lat and long datapoints, my problem is it loads in text perfectly onto exact points I specify on the map,

..well now I want to load in icons(images) instead of text. (yes i'm being difficult)
and i'd like the text to load into a static placeholder symbol instead.

Problem is, I can get images to load in a separate file, text to load in a separate file, and text to appear in a static movieclip...but won't work together in one flash movie....

I can get images to load when load into flash in a separate flash movie, with a movie image with the instance name of picture using this code:
Expand|Select|Wrap|Line Numbers
  1. function loadXML(loaded) {
  2.     if (loaded) {
  3.         xmlNode = this.firstChild;
  4.         image = [];
  5.         total = xmlNode.childNodes.length;
  6.         for (i=0; i<total; i++) {
  7.             image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
  8.         }
  9.         firstImage();
  10.         picture._alpha = 100;
  11.         picture.loadMovie(image[0], 1);
  12.     } 
  13. }
  14. xmlData = new XML();
  15. xmlData.ignoreWhite = true;
  16. xmlData.onLoad = loadXML;
  17. xmlData.load("SVW_SampleData.xml");
  18.  
  19.  

I'll place in the working map code showing text points - as I think you might find it handy (works like googlemaps)
Expand|Select|Wrap|Line Numbers
  1. function processData(success) {
  2.     if (success) {
  3.         movie_Width = Stage.width;
  4.         movie_Height = Stage.height;
  5.         var rootNode = this.firstChild;
  6.         var dataNodes = rootNode.childNodes;
  7.         var dataItemsCount = dataNodes.length;
  8.         minLat = parseFloat(rootNode.attributes.minLat);
  9.         minLng = parseFloat(rootNode.attributes.minLng);
  10.         maxLat = parseFloat(rootNode.attributes.maxLat);
  11.         maxLng = parseFloat(rootNode.attributes.maxLng);
  12.         var dataPoints:Array = new Array();
  13.         for (var i = 0; i<dataItemsCount; i++) {
  14.             dataPoints[i] = _root.attachMovie("sym_marker", i.toString(), i+1);
  15.             dataPoints[i].txt_Label.text = dataNodes[i].attributes.image;
  16.             dataPoints[i]._x = GeoToPixel(parseFloat(dataNodes[i].attributes.lng), minLng, maxLng, movie_Width);
  17.             dataPoints[i]._y = GeoToPixel(parseFloat(dataNodes[i].attributes.lat), minLat, maxLat, movie_Height);
  18.         }
  19.     } else {
  20.         trace("XML Data Not Found");
  21.     }
  22. }
  23. function GeoToPixel(inPoint:Number, inMin:Number, inMax:Number, inMovieDimension:Number):Number {
  24.     return (Math.abs(inPoint)-Math.abs(inMin))/(Math.abs(inMax)-Math.abs(inMin))*inMovieDimension;
  25. }
  26. var xmlData = new XML();
  27. xmlData.ignoreWhite = true;
  28. xmlData.onLoad = processData;
  29. xmlData.load("SVW_SampleData.xml");
  30. var minLat:Number, minLng:Number, maxLat:Number, maxLng:Number;
  31. var movie_Width:Number, movie_Height:Number;
  32.  
(here's the xml file for this for you too:)
Expand|Select|Wrap|Line Numbers
  1. <Advertisers identifier="Food &amp; Wine" datestamp="9-AUGUST-2008 14:50:23"
  2.     minLat="-35.1738083"
  3.     maxLng="148.4912109"
  4.     maxLat="-36.5295019"
  5.     basemap="map_SVWBaseMap.png"
  6.     minLng="146.0687255" categoryid="3">
  7.  
  8.     <Advertiser advertiserid="3" name="Wangaratta" description="get excited!"
  9.              image="icons_silver_art.gif" icon="icons_silver_art.gif"
  10.              lat="-36.3549" lng="146.3076" url="http://www.jammedia.com.au">
  11.     </Advertiser>
  12. </Advertisers>
  13.  
Okay, i'm trying not to get confusing...

the question i'm asking about is in this line of the above code:
Expand|Select|Wrap|Line Numbers
  1. dataPoints[i].txt_Label.text = dataNodes[i].attributes.image
  2.  
I would like some sort of image equivalent code here, instead of calling to a text field called "txt_label" and the suffix of ".text", is there a way to word my above load image script using a blank movie clip, calling to an image linked via the xml from "image" or "icon" field into this line to suit?

Any feedback/ideas at all would be muchly appreciated!
Thanks as always!
=)
Aug 27 '07 #1
2 3419
Hi Again,
I'm sorry, I just realised this may be better suited to the actionscript forum...
I won't re-post to save grumbles, but apologies all the same!
Aug 27 '07 #2
Hi All?
Any Ideas?

Found this on Googlemaps, I think it might be close...
Expand|Select|Wrap|Line Numbers
  1. return new Icon1(c.getAttribute("image"),s)
  2.  
and i'm trying things like:
Expand|Select|Wrap|Line Numbers
  1. for (var i = 0; i<dataItemsCount; i++) {
  2.             datapoints[i].image = picture.loadMovie(image[i], 0, i.toString(), i+1);
  3.             picture._alpha = 100;
  4.  
any ideas would be great!
Thanks!
=)
Aug 28 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Neo Geshel | last post: by
61 posts views Thread by phil-news-nospam | last post: by
1 post views Thread by Steve Belanger | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.