Sign in to follow this  
gwofu

USA map becomes too big after Falsh method calls.

Recommended Posts

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

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 = "&registerWithJS=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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this