Thinking Outside of the Flash Embed Box
30.04.06 @ 9:54 pmAs a Flash Developer, I get very strange looks when I suggest to clients and co-workers not to use Flash as a solution for particular pieces of a project. While I am an advocate for Flash, I also encourage the implementation of Flash in appropriate situations. AJAX is not just a buzz word. It is a very viable method for solving problems that otherwise would have been done in Flash. We should not have to see another basic Flash slideshow using XML to fade images in and out. There are plenty of AJAX slideshows that can perform just as well as Flash (sans high-end motion features).
With the Flash / JavaScript Integration Kit, the doors were opened to allow Flash and Javascript to communicate with each other. While there are some very impressive examples of using Flash and Javascript together, very little seems to have been done with this new method of Flash development. This surprises me greatly as it has completely changed how I approach developing Flash applications.
Background
Using the Flash/Javascript Integration Kit can be as simple as calling an Actionscript function with an onclick using the Flash/Javascript Integration Kit as the medium. This alone adds a whole new level of functionality and flexibility to your Flash applications. However, now it gets interesting as you add another level to it using AJAX.
Many Flash projects I have worked on were chosen to be executed in Flash in order to drive rich media. Subsequently, all other content (including large amounts of copy) were given a second priority in terms of accessibility and functionality. Flash has gotten better about accessibility, but let’s face it, it cannot hang with HTML/CSS. Instead of choosing one technology to drive all your content, this hybrid system opens many doors for what can be done (well) for applications containing both rich media and informational content.
I use XML for every Flash application I work on, be it small or large. It cuts down on development time and allows for more powerful functionality. The drawback with this system is that many times I have to do at least some custom coding for the incoming application data. By using Javascript/AJAX to read/manipulate all the data and subsequently deliver it to Flash, you can pass the exact information needed by each Actionscript class/method. While it is not harder to read XML in Flash than Javascript, with this way you have the opportunity to use the data contained in XML with either AJAX functions or with Flash. Your work is cut in half while doubling your potential functionality as the data can now be delivered via AJAX or Flash. This allows you to create dummy-Flash applications that need to do much less to perform the same task as Javascript is now able to handle everything up front.
Examples
As I have alluded to before, my Javascript is not something to be studied. These examples are rudimentary, but they give you an idea how the two technologies can complement each other. The examples below have been tested in FF 1.5, IE 6.0 and Saf 1.3.2. Credit to Wikipedia for all written content within the examples.
In the first example, you see a basic Flash/Javascript hybrid where Javascript-enabled HTML links are used to call Actionscript functions and all XML data is handled by Flash to display the shape and associated text. This example is simple, but gives an example of how Flash/Javascript hybrid development can improve upon standards-based development.
In the example below, Javascript is handling all the XML up front so that the developer can decide what sort of information should be viewed in Flash (the shape) and what should be viewed in HTML (the associated text). Once again, this example is simple, but all the caveats of accessibility in Flash are avoided as media is shown in Flash and information is displayed in HTML. In addition, the embed size of the swf can be much smaller as it is designed to show only one piece of the puzzle. This can lead to more modular Flash applications with less overhead.
Flash is no longer relegated to its embed dimensions. Flash can be accessed and interacted with from Javascript enabled HTML interfaces. I have spent a tremendous amount of time altering interfaces to create new skins for different dimensions or uses of the same Flash application. This is no longer a necessity as you can leave the interface out of Flash and build it in HTML. The standardistas must be drooling as this is a huge step for more standards-centric Flash design. The Flash developers should be drooling because this means that they will need to reskin application interfaces much less frequently.
Why the Need?
You could argue that the development is being moved from one side (Flash), to the other (Javascript). The advantage with this system, however, is that after your basic functionality is written in Javascript and Actionscript, your interface can be whatever size, shape, language, or color-scheme you desire. All with HTML & CSS. Quickly. Many of these problems can be solved in Flash, however this method seems much more graceful to me as it comes closer to solving the problem at its root. As long as the functionality on the Flash side does not have to be altered, you will never have to open up the FLA file again. Are you excited yet?
Combining AJAX and Flash has already been worked on and, as expected, has already been given its own acronym - FLAJAX. Unlike the AJAX boon, however, FLAJAX has not taken off which leaves me scratching my head. Many of our projects, as designers or developers, include some form of rich media delivery. Flash owns this market hands down, but it is proprietary and relegated to its embedded dimension. HTML/AJAX had pushed forward what static websites can do in terms of media, but it is still lacking in ability. For rich media, a marriage of AJAX and Flash seems logical, if not necessary, for the majority of rich media applications. From my view, this lack of Flash/Javascript cooperation seems to be bottlenecking at the developer level. Many Flash and Javascript developers enjoy their chosen technology and either are not too stoked about learning the other or do not have the time. I am guilty of perpetuating this problem as I, for the most part, fit in the latter category (and a little in the former as well).
Cooperation Is Fun!
The heading above may sound cheesy (because it is), but a little cooperation between Flash and Javascript developers could bring about some very cool applications. I recommend to all Flash and Javascript developers (if you have not already), to check out the Flash/Javascript Integration Kit. Once you read up on it, find your counterpart and get a-coding. There certainly is not a deficit in standards-based rich media applications, so you can pretty much start anywhere. If you come up with a good application, drop me a line (somerandomdude [AT] somerandomdude [DOT] net), as I would love to hear about it.actionscript, AJAX, flajax, flash, javascript, web design web development

April 30th, 2006 at 10:33 pm
$0.00 in Comment Love for October
i learned something new today–FLAJAX. it sounds like a very reasonable and amicable solution for the hardcore flash/javascript fanatic to consider.
i know some flash addicts who REALLY NEED to get off their high horses and read this article in order to improve the way they build sites.
April 30th, 2006 at 11:33 pm
$0.00 in Comment Love for October
Genial… mil gracias.
May 1st, 2006 at 5:03 am
$0.00 in Comment Love for October
I have always been an advocate for well thought out Flash objects, especially when projects require rich multimedia or promotional animations. Flash is an obvious choice when it comes to such requirements but I have also now become a strong advocate for accessibility and Web Standards. The implementation of the Flash/JavaScript Integration Kit is a great step in the right direction. People are often quick to jump on a bandwagon, be it Flash, AJAX or whatever. The flaw that is often overlooked is the use of Best Practise.
The great thing about the FJIK is that it is opening up many more alternatives to the Web and allowing for accessible, degradable solutions which also accomodates for those client project requirements which are often not accessible nor degradable. Allowing for HTML/JavaScript to look after the content and interaction of a webpage and Flash to look after the rich-media aspect really helps developers move in the right direction as to sticking to Best Practises as well as personal “beliefs”.
I’ve not managed to play around with the Kit much so far but hopefully time will permit later in the year and I will get to implement some real-world solutions with it soon.
May 1st, 2006 at 6:09 am
$0.00 in Comment Love for October
There is also this method, AFLAX: http://www.aflax.org/
May 1st, 2006 at 8:16 am
anonymous -
I sense some very strong feelings about this…
Enriue -
De nada
Si -
I’m glad to hear you’re into this method as well. It can take some time at first, but it really makes your life easier in the long run.
Justin -
Thanks for the link Justin, great resource. The only issue I have with that method is that it relies on Flash 8’s ExternalInterface for the communication between Flash and Javascript. ExternalInterface is definitely the better way to go in terms of ease and functionality, but the penetration of Flash Player 8 just isn’t high enough yet. Give it about a year and then I think we will be able to safetly go down the ExternalInterface route.
May 2nd, 2006 at 5:30 am
$0.00 in Comment Love for October
Awesome read. I’m not much of a Flash developer but I am interested in reading about it. Yes, once the ‘buzz’ of AJAX wears off I think it will play a more effective roll than just pretty moving elements. Each technology has its place and I think the use will become more refined over time — which is a good thing.
Just as a side note, a personal preference: I’m not sure why, but seeing any amount of text rendered in Flash is much less aesthetically pleasing for me. I’m not sure why, but the fonts seem to be foggy and harder to read than when rendered as a result of using something such as AJAX. Maybe it is just a peeve of mine, who knows.
Thanks for the good read.
May 2nd, 2006 at 7:07 am
$0.00 in Comment Love for October
I think that comment boxes need a spell check option. How would you go about implementing that?
May 2nd, 2006 at 8:39 am
Jon-
Thanks a lot, I’m glad you enjoyed the article. I do agree that typography in Flash can look very second rate. It has improved greatly in Flash 8, but we as Flash developers cannot use Flash 8 for most projects as the user pentetration is not high enough. Anyhow, this seems to be a solution to the short-term problem.
Leah-
I’d swear you’ve brought that up before… This seems to be a constant theme.
May 2nd, 2006 at 10:54 am
$0.00 in Comment Love for October
We’ve integrated our Flash Video player and a JS stylesheet switcher on the 2006 edition of E3 Insider (http://www.e3insider.com/video). We definitely plan on combining Flash, JS, HTML & CSS a great deal on future projects.
May 2nd, 2006 at 11:56 am
$0.00 in Comment Love for October
Suh Weet! Somerandom dude dot net is probably the best of the best when it comes to blog/magazine/tech know how. Propers PJ.
May 7th, 2006 at 4:01 am
$0.00 in Comment Love for October
I am electrified!
July 25th, 2006 at 2:39 am
$4.00 in Comment Love for October
[…] Escrito por csr el 25 Jul 2006 a las 12:39 pm | Archivado como: Enlaces, CSS (y más) Comencemos con un poco de JavaScript, con una Quick guide to somewhat advanced JavaScript, una de Simple JavaScript Debugging y otra de JavaScript and Selectors. Y un poquito de AJAX. Uno sobre integración de AJAX y JavaScript, un artículo sobre el Dojo Toolkit y otro sobre Spry, la alternativa de Adobe. Y finalmente, un artículo (ˇde mayo!) sobre las entonces últimas evoluciones de la Yahoo! User Interface Library. […]
October 4th, 2006 at 6:00 am
$0.00 in Comment Love for October
Very informative article. I’m a big fan of AJAX and this opens new windows of possibilites for me and my future projects. Thanks for the information.
December 6th, 2007 at 11:01 am
$0.00 in Comment Love for October
Great article. Thanks. I’m struggling with some flash stuff and I’m a bit of a rookie programmer. I have a .swf that defines the menu on my page and I think it is creating a flash layer some of the pages. There is a main link in the middle of the page and sometimes it will not “activate” - it will show that it’s a hyperlink, but you cannot click on it and the page has to be refreshed. Anyway suggestions? I’m working in HTML and calling a .swf file from the css… thanks heaps!