|
CFspark Notes
Requirements:
Flash MX or Flash MX 2004 software, to compile the Flash movie.
ColdFusion MX for the backend server.
Flash notes:
Code is 100% actionscript 1.0, so it can be compiled in either Flash MX or Flash MX 2004.
The compiled .swf file is only 6 KB.
The source code is listed in the "Flash Source Code" link. It is named "sparksource.as.txt" to make it easy to view, but should be renamed to "sparksource.as" before using it in Flash.
Coldfusion notes:
The server component uses a coldfusion cfc to call and parse the Yahoo data, load it into a query object and send it down to the Flash movie. Its coded to retrieve the last 365 days of data, but could be modified for any date range. The actionscript will auto-scale any number of data points sent to the compiled swf.
The Flash Remoting protocol is used to send the data up and down to the flash client. IMHO it is far more efficient than transmitting XML.
Two versions of the CF source code are provided. The first one is what's running the live demo. Most of the code is for retrieving and parsing the Yahoo CSV file and needs work. The second version is what you would need if the data was on a database on your own server. At 14 lines, it shows how little code is needed for a fully functional backend datasource. The future of sparklines is with generating them on your own site, with your own data. Extracting it from another web source (like Yahoo) is not a long term solution to increasing the audience for sparklines. The 4 Internet hops (client-server-Yahoo-server-client) is reason enough to avoid it!
HTML notes:
The flashvars method is used to send the stock symbol from the HTML on the web page to the Flash movie. From there, it is sent up to the server (using flash remoting) to get the intended trading data. More notes are in the HTML source link.
|