gwofu Report post Posted March 19, 2009 Hi, I use swfobject 2 to create a USA Map then try to update the map data by calling Flash methods SetVariable(), Rewind() and Play(). The result is the USA map becomes too big and only part of the map is displayed on the stage. Is it easy to fix it? Here is the code I use: var vars = "chart_id=mapusaid&path=script/&dataXML=" + data; //data : pre-build XML map data var att = {data:FCMap_USA.swf,width:300,height:300}; var swf_params = {allowScriptAccess: "always", flashvars:vars}; swf_params.wmode = "transparent"; var movie = swfobject.createSWF(att, swf_params, "map_usa"); ..... // Build new map XML to data movie.SetVariable('dataXML', data); movie.Rewind(); movie.Play(); // The map becomes too big here. Share this post Link to post Share on other sites
Rahul Kumar Report post Posted March 20, 2009 Hi, We strongly suggest to use FusionCharts.js. Anyway if you are using another method and want to update the chart/map with new XML then you would need to pass registerWithJS=1 parameter to the chart/map in its first rendering, that will expose chart's native method setDataXML to the javascript which you can use to rerender the chart/map with different XML, and also it does not require any Rewind() or Play() method. In your case, you would need to change your code a little bit, please see below: var vars = "®isterWithJS=1&chart_id=mapusaid&path=script/&dataXML=" + data; //data : pre-build XML map data var att = {data:"FCMap_USA.swf",width:"300",height:"300"}; var swf_params = {allowScriptAccess: "always", flashvars:vars}; swf_params.wmode = "transparent"; var movie = swfobject.createSWF(att, swf_params, "map_usa"); ...... // And to update: (Assuming that movie is a global variable) movie.setDataXML(data); If move is not a global variable then: var chart = swfobject.getObjectById("map_usa"); chart.setDataXML(data); Share this post Link to post Share on other sites
gwofu Report post Posted March 20, 2009 Thanks! My problem is solved. Share this post Link to post Share on other sites