Friday, November 20, 2009

What is a Javascript closure?

"a closure is a first-class function with free variables that are bound in the lexical environment"

"a closure is the local variables for a function - kept alive after the function has returned"

"when you pass a method reference out of the context in which it was defined, the method still has access to its parent context"

"a powerful, low level JavaScript library designed for building complex and scalable web applications"


Now the last one will be a bit harder to chew :)

Google released their internal JS library as Open Source code. And it looks sweet.

Until recently I was using Dojo for the better OOP architecture support as opposed to jQuery. Then I realized that the two serve different purposes. Now I use jQuery for augmenting my CakePHP views. It's much easier to do and you have a better chance to find a plugin to use as a base for your needed functionality.

But I wonder if Closure is better than Dojo?

From the first impression it looks that they drew a lot of inspiration from the Dojo Toolkit. Starting with the require/provide directives that instantly made me think "Dojo". I didn't get a chance to dive in yet and I'm still searching for some good online UI demos. I guess those will come soon but not from Google. I don't expect too much support from them and I suspect they'll leave the library follow it's own path once they released it into the wild.

Nevertheless Closure will be a tough player in the Javascript frameworks arena. If Gmail and Docs run on it then it's already production proven. But I guess jQuery is still better for what is normally needed in a web page. For one-page JS apps Dojo and now Chrome with their solid i18n, themes (Closure?) and templates support still rock.

Thursday, November 12, 2009

and your routes shell be free

CakePHP routing and reverse routing does not work properly in shells. That is because your defined routes in routes.php are actually not loaded at all. Maybe 1.3 will fix this but until then read on. 
To have proper routes in the email messages you are sending from shells you need to do this in your shell at the top:


App::import('Core', 'Router');
include CONFIGS . 'routes.php';
define('FULL_BASE_URL', Configure::read('App.HttpHost'));


where App.HttpHost is something you set manually in your bootstrap because the shell doesn't have a clue about your site and the web server.
Bake on!

Thursday, October 22, 2009

To be or not to be

I'd love to have a talk with the guy who made this presentation.

Error #1009 and counting

Back to Flash.

This year I've mostly been hard at work baking cakes one after another. Man I love it!

But yesterday I had to stop and think. You see, I needed a video player. And somehow from all the hmmm, probably 10-15 player I've built, big and small, MVC or timeline scripted, there was not one that I could put my hands on and say to myself "This will do!". That's what u get when u do custom jobs. Maybe I should get into building and selling a customizable flash video player. Wait, what the hell am I thinking!?

So well, I was in need of a good video player. AS3 based. There's no way I'd go and code myself another AS2 player. It's 2009 for God's sake!

Well the truth is I did make a fully customisable AS3 video player that suports all sorts of parameters passed from HTML. but that one used a standard FlvPlayback skin. And it was all good but for the project I'm working on a standard skin was a no-no. I used it for the video moderation in the admin just fine. But does Youtube have a standard skinned flash video player on the front? Does Google? NO!

Hmm, "I need to code meself an AS3 video player" said I to me. Flash IDE is great for drawing but sucks at AS code. Nothing new there. I need an AS3 tool that works with my everyday Eclipse. There was none last time I checked. That's a good while ago though. Easy Eclipse still doesn't have a LAMP version using the latest Eclipse. May be Easy but it's old. I'm still young but time flyes and I can't wait. I'll have to do it the hard way. Got Eclipse Galileo for PHP developers. That's us I thought. I smiled.

Galileo is polished. Cocoa version is snappy. I pointed it to my old workbench and all was there. I slapped Aptana and Subclipse on it and there was nothing more to add. Well except for the AS3 support. Ok I said, ASDT will have to do. I'll pair it with the funky BigSource Zarkov and tame that Flex 3 SDK into submission. Hmmm, "You can find the development site at http://axdt.org". Silly typo... Wait! "enable you to write ActionScript3 code in an integrated environment". Thats me! Had to install IMP for Eclipse too. "meta-tooling for Eclipse". Hmm that sounds metalicious.

Well syntax highlighting didn't work from the start. It did after I installed Colorer take5. But using the IMP editor. Weird. Well...

AXDT rocks! Keeps opening the compiled swf even if I said not to but hey, why not?

Export swc from Flash to the axdt project's lib folder, run from Eclipse, deploy to web server with ANT, debug with Demonsterdebugger.

"TypeError: Error #1009: Cannot access a property or method of a null object reference."

Hmm, good thing I didn't get the other 1008 errors, right?

ADDED_TO_STAGE to follow...

Friday, October 09, 2009

So what's planned for 10.9 I ask?

Well not much...

Except that Flash Profesional CS5 will enable you to build applications for iPhone and iPod touch using ActionScript 3 !!!

These applications can be delivered to iPhone and iPod touch users through the Apple App Store.

A public beta of Flash Professional CS5 with prerelease support for building applications for iPhone is planned for later this year.

Excellent fix for the Open Screen vs Apple problem from Adobe!

Vali can't wait to see that iPhone tab in the Flash Publish Settings and hit that Export to App Store button :)