Tuesday, May 19, 2009

A Good ImageCache for Flex Lists

A while back I brought to life a dream custom component I had wanted for a long time. It's basically a horizontal scrolling thumbnail image holder, the ubiquitous kind that's in everything from YouTube to Flickr. Mine is a little different in that it combines the following:
  • Hover side-scrolling
  • Accurate shuttle indicator below images
  • Accu-sizes to any display object container width
  • and finally...it caches the images for no lag
Pretty much does the job for me. I'll post it soon, happy to share and hear feedback on it. And on that note, I ran across a legacy of cache issue explorations and solutions by other flex scripters. The earlier one, which I noted but haven't tried out, is Ely's SuperImage from a couple of years back. It touches on the all-important performance issue of non-caching assets in Flex components.

The follow-up, which I'm stoked to note is lean, lithe and easy to plug in, is thanksMister's ImageCache. There's even a sample app using the Flickr API. Tested and hereby endorsed. Hope you get some use out of it.

Monday, May 11, 2009

Flex talking to Flash

Here's another good refresher on getting a Flex app synched up with Flash swf resources, this time at giantflyingsaucer.com. I'll post a link to a tutorial on Flex with Flash-compiled swcs as soon as I come across one. Any favorites out there?

Accessing swf vars from Flex

Ever need your memory jogged on the topic of putting swf vars into your Flex app? Here's just the thing for that:

Flash cs3 as3 file "click.swf"

ActionScript Code:
click_mc.addEventListener(MouseEvent.CLICK, reportClick);
var output:String = new String();

function reportClick(evt:MouseEvent):void
{
for(var i:int = 0; i<5; i++) {
output += "I have been clicked. i = " + i + "\n";
}
}

MXML Flex 2.0
ActionScript Code:
<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>
<![CDATA[
private function updateTextField():void
{
output_txt.text += swf.content["output"];
}
]]>
</mx:Script>

<mx:SWFLoader x="10" y="10" source="click.swf" scaleContent="false" id="swf" click="updateTextField()"/>

<mx:TextArea x="10" y="518" width="550" height="211" id="output_txt"/>

</mx:Application>

Made for Flex 2 but perfectly applicable to 3, 4 and perhaps beyond... Thanks to the forums at actionscript.org for this one.

Saturday, May 9, 2009

Poster REST App for Firefox

Pretty useful plug in here to allow what otherwise requires modules, DLLs or IDEs. Don't know how I got by without it for so long.

Get Poster

On the PS side, why do low-level service applications typically lack quick client integration options? My web services visualization tool is the browser, not a command line or SDK. So let's put that app into the browser.

Poster does that. Thanks to creator Alex Milowski. Read his blog.

Thursday, May 7, 2009

Beginnings of an RIA ECommerce solution

Another round of tests and some interesting results. I have successfully stubbed the mySQL database into Flex via .Net procedures created by WebORB. Also, I have added fields to the mySQL tables of interest without any unique key violations in the Miva CMS. I had to add primary keys to several tables in the database, but as stated, no adverse affects, meaning the db queries in miva's cms are fairly fast and loose. In this case that is a good thing.

Still working on the details, but so far it seems possible to do the following:
  • Use Miva Merchant 5.5 as a backend solution for a rich ecommerce (web) application
  • Use Flex 3 as a client frontend with RPC enabled products arriving from Miva
  • Add custom fields as needed to elaborate on the data the Miva CMS typically allows
That's a good start. The test verifies an architecture consisting of Miva -> MySQL -> .NET -> Flex on the incoming side.

Now I'm looking into solutions for the Flex -> Google Checkout -> Miva on the shopping cart transaction side. For now, going to checkout will out of necessity pop out of the RIA window and open another. It's a small price to pay, especially considering there are virtually no single-state checkouts anywhere on the web. It hasn't hit the production line yet.

Since Miva is stable with additional fields in its DB but cannot administer the extra fields, my wishlist of useful add-ons now includes a secure Flex-based CRUD-enabled CMS to manage the custom fields added to Miva DB tables. It would be great to be able to post images and data through a form in Flex, and very possible time-permitting. For now, the method is direct DB data injection and FTP posting. Not good for a client admin, but fine for a developer at this point.

And the point is, it works!

Wednesday, May 6, 2009

More Miva Merchant

There have been some interesting revelations here. What I've found can be summarized thus:
  • Miva Merchant up to vers 4 uses a proprietary form of SQL called MIVA SQL. While it uses Structured Query Language, it does not share compatibility with MS SQL. Thus it is locked in its own fishbowl.
  • Miva Merchant 5 and on to current 5.5 gives resellers the option of configuring their product to reposit with MySQL instead of MIVA SQL, which provides a substantial performance boost. My webhost of choice for this project opted for the MySQL configuration. This is good.
  • Miva Merchant offers a range of export options for financials, including .dat files and the like. They do not currently offer any RESTful services of any kind. Thus the question of whether to REST or RPC for Miva is conclusively RPC or bust.
Contacting both HostMySite and Miva Tech Support in CA has confirmed the above. They recommend using Miva forums, but there is but scant info on this topic that I have found. The webhost tech department has been very cool and receptive to my questions and has custom configured my Miva-driven MySQL DB to allow me to connect and read data directly from it. This means there is finally a way to export data from the CMS portion of Miva and feed it to my custom Flex front end.

Now then.

The question remains, how will WebORB interpret the schema of this Miva-built DB? I hope well. Hand-coding RPC is out of the budget and timeline for this project. I am relying on the savvy of WebORB to translate the schema into useful server and client side code libraries such that, if all goes well, I can pull the inventory on the fly from Miva to my Flex application.

Between this and a lack of experience working with a MySQL .NET hybrid, I'm hoping it will go smoothly. I'm now creating the DSN to allow ODBC between the weborbconsole and MySQL, so I'll let you know what happens.

MIVA MERCHANT

Working on a Flex ecommerce solution. Need to provide the client with a full suite of merchant tools including:
  • Pre-provided tax rate data on orders within the US
  • Price and quantity inventory info
  • Fulfillment and basic CRM features
  • Analytics
  • Easy-to-use content management
  • API to Google Checkout
  • Portable to external spreadsheets and financial software
  • Secure credit card transactions (natch)
Plenty of solutions offer the above. The catch is, in order to provide my own client side in Flex I require a direct db connection, preferably to SQL, to supply a stream of remote data to my shopping UI. I have created my own CMS that will do the job, but there are ornery caveats associated with an architecture including 2 repositories of data, my CMS and the ecommerce CMS, namely:
  • consistency of state across tiers
  • concurrency
  • locking
  • transactions
  • rollback
Dual databases for one application is seldom if ever ideal, and certainly not in this case. Trouble is, unless there is some way to communicate between Flex and the Ecommerce solution, 2 databases are the only way to roll it out. But what form would this communication take? In the case of Flex, there are three services available for accessing data:
  • HTTPService: Passes textual data over HTTP. This is often used to fetch RSS feeds, read XML generated by a server, or simply pass text-based data from server to client.
  • WebService: Allows a Flex application to invoke server-side web services using SOAP and handle the results of web service calls. These web services may reside on the server that has served the rich Internet application or may call third-party web services through a proxy on the server.
  • RemoteObject: Allows a Flex application to directly invoke methods on Java classes residing on the application server that has served the RIA. Data is transferred in binary format (Adobe Action Message Format or AMF) over HTTP or HTTPS, with the server translating Java and ActionScript objects as they pass over the wire.
That's a pretty rich options list. I can use RSS feeds, XML, Web services or even direct DB access via RemoteObject. Lots of options, yes, options galore. As for the custom CMS I mentioned, it is .NET and uses RemoteObject to pull from the SQL database. Now I seek a similar means of pulling data from the ecommerce system. Any will do. But as it appears, there are few options.

I have thorougly scoured practical ecommerce, a website devoted to ecommerce application vendors. Practical ecommerce website has a Cart of the Week feature in which they interview principals of a web ecommerce provider each week, weighing the pros and cons of their service. There are open source solutions, Microsoft solutions, Adobe solutions, many variants. They can be hosted or licensed options. I've read through many of them.

In addition, I have signed up for Miva Merchant 5.5 with the reseller that hosts my client site. They are one of the 800 pound gorillas of ecommerce, Google Checkout being the reigning heavyweight, but not a full service solution as Miva offers.

Miva Merchant offers database integration now, as of 5.5, via the services of MIVA SQL and optional MySQL support, but here's the rub. Try a google search for "miva sql" and venture a guess at the richness of answers google will provide. At my last search...462 pages. A pathetic level of information out there to say the least, and equally untenable are the docs offered by Miva. Here are a few plaintive queries that died on the vine on my hosting account forums:
I've put in a support request ticket and will continue to pursue the issue. For my stake in this, at the root of the matter lies a question of Flex and Ecommerce integration. I ask the ecommerce vendor community collectively, is there a solution that offers a full set of features as well as database access? Has any of the companies seen the value in offering a solution that can serve as a data feed and cms, or conversely are they all template-and-markup-based solutions? I'll post more once I have some concrete answers to this.

Monday, May 4, 2009

More Bugs In App Development

Encountered a scenario recently that underscores the difficulty of working in a multi-tier web app architecture. Recent project was SQL to .NET CMS and a Flex client side, spanned by Weborb.

Problem came about when I updated the .NET CMS, suddenly the front end flex app started throwing the application error, ____, stating a method in my weborb-generated code was coming up null. This was strangely the case not only for my code, but for the autogenerated testdrive as well.

I chalked it up to a misnamed package on either the server or client side, later to find that troubleshooting it was not helpful. I replaced the service locator xml files from my base install, which also did nothing to help.

Finally I built a test case and slowly bridged it from working to nonworking case, using varying test cases similar to the nonworking build. After lots of wasted time, I found what is either a memory leak, or an Eclipse bug.

Either way, I had to work around it and ultimately create a new build that is identical - as far as I can tell - to the nonworking version. Only it works.

The tier problem I speak of is the many levels of unknown in the overall architecture. It is difficult and time consuming to isolate layers one at a time to find the culprit. It would suggest that rich media apps require a team of specialized workers. Takes too long.