Click to See Complete Forum and Search --> : xml to generate graphic??

07-05-2001, 08:08 AM
strange question I think, but maybe not.

I want flash to be able to generate a diagram on the fly from an xml document containing numbers..

the reason it has to be on the fly is that the xml doc is being generated from a sql query.

once within flash is it possible to use xml to position a graphic or a movieclip.

these are things I know little about but if anyone can guide I would be most grateful



Hannibal Barca
07-05-2001, 11:28 AM
No clue personally. Your idea's interesting. I'm latching on to the thread to see what responses you get.


07-05-2001, 12:16 PM
It is not that difficult to create graphs etc in flash using duplicated movie clips.

For example the thinking behind a bar graph would be:

You create a very thin movie clip that is a certain width, but basicly a rectangle. Then you define the area that you want to have your bar graph appear in.

You count the number of items that you want to graph, and work out how big each bar should be by scaling the movie clip. For height (getting this from the XML data) scale the movie clip upwards.

Each element of data in the XML could specify a new movie clip each with their own properties.

If you are interested (or just can't understand what I am on about) I might clean up one of my bar graph style apps which I created for playing around and let people at the source.



07-05-2001, 03:28 PM
I would be very interested in seeing this xml-to-flash bar chart open source file. It's something that I'm very interested in (manipulating Flash with XML...and vice-versa).

I believe that I follow you so far. I also remember having seen this implemented before on the web (URL escapes me at present) to display polling results without breaking the flash interface of the site.

Anyway, I'd be interested in seeing an open source file.


07-06-2001, 02:38 AM
The book Flash 5 Dynamic Content Studio has a tutorial on this exact subject... you may want to look into it. In fact, that seems to be an awesome book all around.

Really, if you think about it, it's quite simple. If you are advanced enough to write an XML doc to your server using ASP or Perl or whatever (that's the part I have trouble with) you should be able to make a bar chart in flash. In fact, I will write the flash code if you get the Perl script to work for me.

Try this:
Load variables from your XML file.... looking for variables named answer1, answer2, answer3...... then use this code:<b>
bar1percent = Math.round(Number(answer1)/Number(total)*100);
bar2percent = Math.round(Number(answer2)/Number(total)*100);
bar3percent = Math.round(Number(answer3)/Number(total)*100);
stop ();
[Edited by marigold on 07-06-2001 at 02:46 AM]

07-06-2001, 10:11 AM
Thanks for the book recommendation and the script. Looking at the actionscript, I have to agree that the harder part is indeed rendering the XML doc dynamically rather than importing into Flash.

I will certainly be pursuing dynamic content studio for more ideas.

I'm no scripting wizard but is there any particular reason that you have to use Perl? Personally I am looking to develop the backend of my web app in JSP, thereby gaining some form of platform independence (theoretically). Although, this project is currently on hold whilst I coordinate a relocation IRL.

Do you know of any good tutorials online for generating dynamic flash (w/o invoking Generator or Turbine)?

Much appreciated,

07-06-2001, 11:46 AM
You should be able to use any scripting language to generate your XML data. As long as they output properly formatted XML (which JSP can do) you are set.



07-06-2001, 11:50 AM

I have no problem with generating the XML - I am generating it using asp - If you want the code let me know in fact to change this to perlscript shouldn't be a problem either.
In fact I bundled together a high score system for a game that draws xml from sql server using asp then draws it into flash, however it just displays it rather than doing anything constructive once inside - this is what I am interested in. (http://www.davidaanensen.com/dotcombat)


I saw a program called jgenerator the other day that might be of use, other than that the friends of ed books are damn fine indeed.