AS3: Creating static XML with ColdFusion and AIR

To build off of a couple posts earlier, the following is an example of how to access the Yahoo stock information and create a static XML with AIR file that Flash can access. I went this route after seeing the server hit that we took when 3k+ users logged in at the same time and tried to access the stock ticker. The stock ticker was hitting the Yahoo service every few seconds and was significantly slowing things down. What I decided to do was to still use the CF service to access the stocks, but instead hit it with an AIR app that then takes that information and creates a static XML file for the Flash stock ticker to access. This also solved the “after hours” stock information as the Flash file would always be hitting the static XML, which wouldn’t change after 5:00 PM. So, to define the process, Yahoo delivers stock information, the AIR application is triggered by the server via a scheduled task, AIR accesses the ColdFusion file that hits Yahoo for the stock information, then AIR takes that information and creates a static XML file. This basically took the hit to Yahoo to once every 5 minutes by ONE application, rather than once every few seconds by any number of web hits…typically at least 1k…
AS3: Yahoo Stocks, Flash and ColdFusion
After searching high and low for a good resource of semi-up-to-the-minute updated stock feeds I came to the conclusion that there aren’t any, for free anyway. I dug into the Google Finance and Data API’s, and made a lot of headway there writing the authentication methods in JavaScript, then in PHP, then in .NET…but was not able to pull something together (quickly) . I plan on revisiting that path, but I digress. I turned to the Yahoo file download that you access via http and it returns a .csv full of stock data from opening trade, current change, volume, etc. This was perfect but how do I convert that to a format that Flash can read?
I used the URLLoader method to load the data, converted it to an Array by splitting at the commas, and then loaded the different values I need by accessing a certain part of the array. This worked perfectly, locally, but then I placed it on our intranet (final resting place), and nothing showed up. Come to find out, the cross domain policies were preventing access to the file on Yahoo’s server. So to make things easier in the long run I wrote a proxy in ColdFusion that the Flash app calls to obtain the stock data. Enough of my explanations and on to the meat…


Recent Comments
connatser on AS3 Playground: Simple Particles:
thanks Richard, and thanks for checking it out!...
connatser on AS3: Motion Blurring with Flash, part 1:
I agree, thanks. I will get some source files together and update the post....
Chris on AS3: Motion Blurring with Flash, part 1:
would be a lot easier to follow this tute for a beginner if you'd inclu...
rv on AS3 Playground: Simple Particles:
great example, nice job....
ericfickes on 360Flex: Stoked to get a break and hear great devs.:
Hey Brian, be sure to say hi at 360. Jun and I are pretty excited about th...