Actionscript 3

AS3 Open Source: Custom Form Validation

01/20/2010 in RIA View Comments

During a normal week I may write 2-3 form based applications in either Flash or Flex and each of them have specific form values that need validated. Last week I decided to begin to write a custom validator in Pure AS3 that I can reuse and simply pass it an array of information to validate against. The first iteration is a simple check against a value and a parameter of what would make it invalid, for example a String and if it == “”. The validation built into Flex is “ok”, but I needed some more portable, extensible and very reusable.

I have included a sample test instantiation for using the classes, simply checking for String values, but you can pass basically anything you like to the validator and it will check the value against the parameter that would make it invalid. I am sure this will change a lot over the next few weeks as I add validation types, values and such, so I will continue to commit the source to git. I am trying to keep it as generic as possible, to use in both Flash and Flex projects. Custom events are fired on pass and fail, passing along an array of information based on the fields that failed. You can then call your methods to submit the form or throw Alerts, etc…up to you.

I have posted the initial classes on my github account with an MIT Open Source license.

You can grab the early framework or fork the repository at github here > NumbKnuckle Validator

Flash and FDT: Simple workflow video

01/03/2010 in RIA View Comments

One thing I have been wanting to do is create a demo showing a simple walk through with Flash CS4 IDE and the FDT Actionscript 3.0 editor. Some things early on messed with my head and were hard to get just right, so hopefully this walk through will help out anyone starting to use FDT as their AS3 editor of choice.

Get the associated FL_Package class I speak about here.

Flex Framework: RobotLegs simple demo

01/02/2010 in RIA View Comments

I have finally dug into the RobotLegs framework and learned enough about the workflow and idea to put together a quick video demo. The demo runs through setting up a simple project that actually utilizes the framework and injects data from a model into a TextArea. I hope you enjoy and possibly even learn a thing or two. Nevermind the yelling kids and wife…and barking dogs :) .

Click here for the demo.

If you have trouble viewing the video, you can [Right Click Here] to download the video locally. It’s around 50mb and a QuickTime video.

Source code can be obtained here and a short demo on git can be viewed here.

AS3: Creating static XML with ColdFusion and AIR

01/02/2010 in RIA View Comments

stockAIR
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…

Read more

AS3: Yahoo Stocks via PHP Proxy

01/02/2010 in RIA View Comments

To follow a recent post about AS3 and Yahoo stocks using ColdFusion as a proxy below is some code to get the same information using PHP. I have been asked by several people on how to do this with PHP, which is not my typical scripting language. I decided to dig into it to see what the comparable method in PHP is to CFHTTP.FileContent. Turns out that the comparable function in PHP is “file_get_contents”.

<?php
//Get the file content and assign the string to $teststock
$teststock = file_get_contents('http://download.finance.yahoo.com/d/quotes.csv?s=^DJI&f=sl1d1t1c1ohgv&e=.csv');
 
//Split the string into an array to access each property of the stock
$teststring = split(",",$teststock);
 
//Print the new array to the screen
print_r($teststring);
 
print("<br /><br />");
 
//Print a specific point in the array, in this case the first one
print_r($teststring[0]);
 
print("<br /><br />");
 
//Print a specific point in the array, in this case the second one
print_r($teststring[1]);
 
?>