Comments
Patrick Collands wrote: collands (AT) gmail com I'd be very grateful for an invitation. Thank you.
Cloud Computing
Conference & Expo
November 2-4, 2009 NYC
Register Today and SAVE !..

SYS-CON.TV
Today's Top SOA Links


AJAX, JSON, PHP, and Flex Together
Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes

Then, we hack around a bit. First of all, we need to convert the data to JSON format:

toJsonString( notifier.data )

We also need to minimize it, because Flex's JSON Library doesn't like new lines or carriage returns in that data (this took me a long time to figure out!). So, we run:

jsmin( toJsonString( notifier.data ) )
Finally, we pas the result of that function to the method in our MXML file, bindJSONToChart():
bindJSONToChart( jsmin( toJsonString( notifier.data ) ) );
I'm lazy and I've made that all one line in the code.

Now, it will do that fine if the .swf file has loaded. However, sometimes the data gets returned before the .swf file is actually loaded. I found this out when running the application locally. So, I've wrapped all this in a try / catch statement, and added an initialization function on the swf file, so that if its not loaded, when it loads it will run this function and populate the graph with data from the Ajax call.

There you go. When you load the HTML page, Spry will load that PHP file using an Ajax call, the PHP file will connect to Feedburner, get the XML data, print it out. Spry will read that in, bind it to the HTML elements on the page, then call the Flex application, passing it the data in JSON format. The Flex application will read in the data and display it in a Flex chart. Here are a few tips and tricks that I've found when building this out:

1.  I found it easiest to modify the HTML that gets output by Flex Builder, rather than to reference the built swf file. If you do that, be sure to modify index.template.html in the html-template folder of your Flex project, rather than the .html files in the bin/ directory of your Flex project. The HTML files in bin/ get overwritten when you save and re-build your Flex application, and if you modify those, rather than index.template.html, you'll lose your changes.

2.  I started building out the Flex graph using JavaScript and the Flex / Ajax bridge. I don't recommend that. Build out your entire Flex component in Flex Builder, then simply write functions to pass data to it from HTML. I think that's easier than trying to build Flex components using JavaScript.

3.  Similarly, write functions that closely couple your Flex application to your HTML page. For instance, you'll notice that in my MXML file, I call the chartClicked JS function using:if( ExternalInterface.available )

ExternalInterface.call("chartClicked", clickEvent.hitData.item);

I could have attached an observer to the lineChart instead, using the Flex / Ajax bridge, but I find it easier to get the data items and debug the application in Flex Builder, rather than trying to do that in JavaScript on the HTML page.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.

We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.


Your Feedback
j j wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
AJAXWorld News Desk wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
AJAXWorld News Desk wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
CFDJ News Desk wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
SYS-CON Brazil News Desk wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
SYS-CON Australia News Desk wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
n d wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
JDJ News Desk wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
SYS-CON Italy News Desk wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
Web Developer's & Designer's Journal wrote: We've all seen Google finance, and the great job that it does at mixing HTML content with Flash content, as seen on company stock quotes. Google has done a great job at using Flash where it makes the most sense, in the graphs for company quotes, with HTML where it makes sense (linking to news items). Today, I'll show you how to build your own Google-finance type site, using a combination of Ajax, JSON, PHP and Flex / Flash. And, best of all, we'll do it all for free.
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE