Server side actionscript – Hacking Tamarin

Filed under: AIR, Adobe, Flash, Flex — Wrote by Campbell on Saturday, August 8th, 2009 @ 12:59 am

As mentioned in my previous post I have been on a short holiday. One of the things I slated to do at nights was to dig deeper into the Tamarin project.

“The Tamarin virtual machine is used within the Adobe® Flash® Player and is also being adopted for use by projects outside Adobe.” - http://www.mozilla.org/projects/tamarin/

Just to start out, I highly recommend having a look through the source if you have any understanding of c/c++ and are working with the flash player at any level. Playing with it I have learnt so much about what really goes on under the hood. I can only liken it to being a mechanic and driver at the same time compared to being just a driver. Things are fine as a driver while everything is going as planned, but when things go wrong as a mechanic as well you can tell whats going on behind the scenes and can make fixes (educated guesses) very quickly.

I began by just extending the virtual machine in c++, and soon found myself adding database abilities. These could then be in turn called from actionscript. This ineviatably led me to looking into server side actionscript. I found the mod_actionscript project on Google code and used this as a rough guidline to do my implementation. I wrapped the virtual machine in a Fast CGI wrapper. This allowed the application to remain loaded inbetween requests and just start from an entry point in the actionscript. Soon I had raw compiled actionscript returning text from Apache. And wow its fast. I have now started building a bit of an actionscript core for fun, giving it activerecord (think rails) like capabilities.

Im starting to look at the different web focused frameworks out there and how they might fit with this. Google Web Toolkit is a really nice implementation, and I can see now why it is like it is. More of a javascript application than web pages. GWT allows the strongly typed world of Java to work well against tested javascript components, forming the larger application. Then theres the rails style. Convention over configuration, loosely typed objects etc. I really love rails but I also love the debugging of Actionscript, which requires the Strongly typed objects. So Im unsure where Ill take things, but for now I will keep playing.

It sucks that the development tools are very limited, jumping from Xcode, to eclipse, to textmate etc but still fun hacking. I have even given the little project a name; RedRocket. And I found a now un-used logo for it ;)

(hehehehe)

All this leads me to the question that has been bugging me for the past week. What ever happened to the examples we saw glimpses of during max last year. They showed actionscript sections inside of an HTML page, being executed on the server.

http://www.youtube.com/watch?v=uImhKFhwAu0&feature=player_embedded

Does anyone have a link to this? Was it just some side project of the developers at Adobe? Did it get canned with the current economic situation. Was it killed as it competed with Cold Fusion to much? – Does anyone know….. does anyone care?

Compile C/C++ libraries into your swf

Filed under: AIR, Adobe, Flash, Flex, MS .NET — Wrote by Campbell on Wednesday, November 19th, 2008 @ 9:14 am

Sounds cool huh? You look at all the projects on sourcefourge and think, man if only I could do that in the flash player. Well now you can. The project named Alchemy which translates these C and C++ libraries into bytecode for the flash player is now available on Labs. I cant wait to see how people bend and twist this one. I think it may be one of the more interesting projects I have herd come out of MAX so far.

The Download and Documentation as always is displayed and well laid out on Labs:

http://labs.adobe.com/technologies/alchemy/

Looks like its a pretty intensive install for Windows, but Mac looks fine :)

Adobe is providing some example libraries, and developers are encouraged to share their ported libraries.

On another note one thing mentioned in the 2nd Keynote spiked my interest:

“Ben then opens up Visual Studio and edits MXML with color coding in Visual Studio using a new plugin Adobe is creating. Next he shows a native AMF to .net implementation to build a back-end in C#.”

Hmmm to tell you the truth if the plugin for Visual Studio works well, I might end up doing my flex work in that. I never use the visual layout features of Flex Builder these days and Thermo….  I mean Catalyst will do that work for me.

 

Thermo, Cocomo, Growl and sooo much more

Filed under: AIR, Adobe, Flash, Flex — Wrote by Campbell on Tuesday, November 18th, 2008 @ 9:57 am

Wow what a day. The press releases are running thick and fast from Adobe today.

First up Thermo, now known as Flash Catalyst. All attendees of the keynote aparently recieved a sneek peek DVD of therm… err hmmm Flash Catalyst. I have Kai bringing me back a copy :) This will be an interesting one to play with, and I know most developers will be looking at the generated code quality as this was a big concern.

Also the AIR runtime has had a new version release. 1.5. head over to the ushal place to get the release http://get.adobe.com/air/

Cocomo went public beta too:

“Cocomo basically leverages the Adobe Connect back-end to deliver features such as Data Messaging (think traditional Remote SharedObjects), VoIP Audio, Webcam Video, File Sharing, Text Chat and so on. The tool is provided in shape of a developer framework and component set that can be used to build Flex based applications.” - flashcomguru.com

This should be a great help to moving the video/voip platforms forward, though I will watch with caution as to how Adobe charge for this. If its anything like their localized sales of software, be afraid, be very afraid.

Also on the video front Flash Media server version 3.5 was announced with dynamic streaming and DVR features (New Zealanders think My Sky for live video on the web).

“Dynamic Streaming makes it easier to deliver a consistent stream even when bandwidth conditions and general network health changes during playback. While similar techniques were possible before it is now even easier and in particular much more seamless to integrate this functionality.
The DVR feature is great when viewing live streams, either to rewind back to the beginning of the broadcast or simply to re-view a certain part of the stream. I can see this being a great feature for sports broadcasts in particular.”  - flashcomguru.com

Also announced was a new Flex features tour app. This is something I suggested to Microsoft on the launch of silverlight. Its the best way to just “play” with the controls and think about what it could do etc. 

The app is an AIR app (which needs AIR 1.5) and shows you through the controls, and it seems that user submission of examples is coming to :)

Adobe also announced a new product called Wave 

“Adobe® Wave™ is an Adobe AIR application and Adobe hosted service that work together to enable desktop notifications. It helps publishers stay connected to your customers and lets users avoid the email clutter of dozens of newsletters and social network update messages.”

Still unsure about this one….

Flash player 10 for Mobile!!!! almost fully featured. Adobe has been working with ARM to have an almost fully featured Flash player 10 on the ARM processor. I guess this means that the open screen project is actually moving forward. I cant wait for the day I can hack the set top box at home with a different AIR app :) .

“Obviously hardware may be a limitation, but demos were shown on Symbian, Win mobile and Android (sorry, no FP on iPhone yet…that’s in Apple’s hands)” - philterdesign.com

Lastly a very cool post from Mike Chambers blog about the AIR framework accessing the Growl notifications on mac. Adobe offered to (and subsequently did) help the open-source project along by adding TCP support, instead of the only option of UDP (which the flash player doesn’t support *sigh*). This version of Growl isn’t released yet but will be soon, and is available from the nightlies. Head over to Mike’s blog for more, and the google project for a lib.

So enough of the re-spout of Adobe announcements. But I thought some of these were too good not to pass on. “We now return you to your regular viewing”….

Hessian and the Iphone (IRemoting for the Masses)

Filed under: Adobe, Flex, MS .NET — Wrote by Campbell on Tuesday, August 19th, 2008 @ 5:23 pm

Well I splashed out on the Iphone 2 and one of the first things I did was go an grab an Objective C book and sit down to sort this new lanuage out :)

2 weeks later I am versed enough at the principals of Objective C to start causing trouble. I must admit its a very different syntax. The first thing I found laborious was xml and http handling. I was accessing web services on my web server just mucking around an it was so painful. Having come from the wonderfull worlds of Flex Remoting coupled with .NET through WebOrb I started thinking there must be a better way.

Guess what there is!

After running round and learning a few new things I was exposing methods in my .NET dlls to the Iphone using common Objects through a service. All Binary too :) Sound familiar? Well it should, its what Flex remoting is. I couldn’t use AMF though as I couldn’t find an AMF sterilizer in Objective C and definitely wasn’t wanting to write one with my work load at the moment.

What I did find for now was Hessian, which covers a range of languages. After a setting up unit tests, I was passing native objects from each Language to the other (Iphone Objective C to .NET C#) in my unit tests and got all basic and complex types working along with custom classes etc. So now its off to build an app with this in hand. 

Depending on how your objects are structured you can see a huge compression of the objects compared to markup (XML) alternatives. I was seeing 100kb xml to 9kb hessian protocol. Definitely something to look at with New Zealand’s 3G Data prices. And to top it off its less code than parsing xml, faster to develop and faster to use. Give me a yell if you want more info as it can be easily transported to ROR, Java etc.

Now if only Apple would hurry up and allow me onto the Iphone Developer program! its been two weeks!!!

Wouldn’t it be lovely to have the data pushes and streaming of Flash remoting on the Iphone. Stay tuned! ;)

The magic of “[Binding]“

Filed under: Adobe, Flex — Wrote by Campbell on Friday, June 27th, 2008 @ 1:07 am

Having been on my Metadata train of though I finally found the time to hunt out in the compiler source where this all happens. Please bear in mind I am no Java buff, nor do I claim to be. In fact quite the opposite ;)

Basically there are a list of Metadata tags in the Flex framework that when they appear in your AS3 or Mxml source, they get “preprocessed” by the compiler. Basically the compiler looks for these tags and modifies the code that appears below it according to a template. I was looking into how I could add my own “preprocessed” tags to the mix and unfortunately it seems that a custom build of the compiler would be the only solution :( (please correct me if I am wrong)

If you would like to see what happens.. The compiler uses a .vm file (some strange Macro file) to add watchers and setup functions to your classes for [Bindable] etc.  Check out the ClassDefLib.vm file and scroll to the bottom and you will see:

#**
 *
 *	emitBindingsSetup
 *
 *#

Below the comments you might be able to figure out how it builds up the bindingsSetup function.

But I digress. The whole point of me tracking this down so I could… well for lack of a better work… Hack the compiler for my own selfish needs.

I find myself asking the question “are there more people out there that want to do the same“, have their own preprocessors for Metatags and build up their own libraries of time saving “preprocessors”. I imagine so. I guess it comes in under the feature request area.

I would love to see us as developers have some config file where we specify the tag and the appropriate template file and the compiler runs off and does some of the hard repetitive coding for me. We could specify a xslt file and knowing the variables that might be coming in would could build/add to code source.

[CampbellsSuperTag] :: someTeplateFilepath.xslt

Off to http://opensource.adobe.com I go….

© Flex developer, Campbell Anderson, from New Zealand – xsive blog -