Archive for March, 2007

Loading charts into another swf

Wednesday, March 21st, 2007

You can load any chart in to another swf file. The following example is made for Line & Area chart, However you only need to change all occurrences of "amline" to "amcolumn" or "ampie" or "amxy" and this will work for other charts. Here is the code, copy and paste it to your flash movie:

var listener:Object = new Object(); listener.onLoadComplete = function(target_mc:MovieClip):Void { target_mc.path = "amline/"; target_mc.settings_file = "amline/amline_settings.xml"; target_mc.data_file = "amline/amline_data.xml"; target_mc.flash_width = "550"; target_mc.flash_height = "400"; } var loader:MovieClipLoader = new MovieClipLoader(); loader.addListener(listener); this.createEmptyMovieClip("amline_mc", this.getNextHighestDepth()); loader.loadClip("amline/amline.swf", this.amline_mc);

With current settings your swf file should be saved in the same folder where amline.html is. Do not forget to change paths if you save it to a different location.

When chart is loaded to your parent swf, stage alignment will be changed to "TOP-LEFT". if you don’t want this to happen, add this line to you onLoadComplete function:

target_mc.align = "";

The same with scaling – if you don’t want to use "noScale", add this line:

target_mc.scale = "";

Download example loader.fla file.

Resizing chart when window is resized

Monday, March 12th, 2007

To resize charts together with the window, you need to set height or width of your flash movie in percents. This is done in this line of html:

var so = new SWFObject("amline/amline.swf", "amline", "100%", "400", "8", "#FFFFFF");

This line says that width of your flash width will be equal to 100% of your window (table, div..) and height will be equal to 400 px. if you want your chart to resize together with a window, you have to set:

<redraw>true</redraw>

Note that if your legend, labels, and other objects have fixed X, Y and Width properties, they will not be changed.

About

Thursday, March 8th, 2007

I am freelace flash developer. I live in Vilnius, Lithuania. I am 29.

Currently I am focused on two of my projects – interactive maps and flash charts. This blog is mostly devoted to these projects.