dat-gui: A Lightweight GUI for JavaScript Variables

November 19th, 2012 by Adrian


Recently I’ve started using this really cool lightweight GUI for allowing the easy tweaking of your JavaScript variables at runtime. It’s called dat-gui and it is available for download from the Chrome experiments website. The source code is hosted on Google Code and there is a handy tutorial showing how to use it here.

It makes it really easy to display sliders, colour pickers, checkboxes, buttons, drop-down menus etc in a nice clean panel (that can also be hidden) that update your JavaScript variables on-the-fly. It is also possible to create presets and save bespoke settings.

The interface looks something like this …

dat-gui Example

Here is my example of it in use.

Canvas Experiment 22

Posted in Canvas, Javascript | No Comments »

JSConf EU 2012 – Videos Online

November 19th, 2012 by Adrian

JSConf EU 2012

Back in October JSConf EU took place in Berlin. I wasn’t aware of it at the time, but it has now come to my attention that the sessions are now available online for free.

There were some great speakers including Anders Heijlsberg, Mr.doob and Remy Sharp. Check out the list below …

All the videos are available on their YouTube channel here.

Posted in Conferences and Events, Javascript | No Comments »

JSConf 2012 – Videos Online

November 16th, 2012 by Adrian

Back in April JSConf 2012 was held in Scottsdale, Arizona. I wasn’t aware of it at the time, but it has now come to my attention that the sessions are now available online for free.

There were some great speaks including Remy Sharp and Paul Irish. Check out the list below …

Posted in Conferences and Events, Javascript | No Comments »

HTML, CSS & JS Online Code Editors/Playgrounds

October 10th, 2012 by Adrian

Over the last year or so there has been increase in the number of online HTML, CSS & JS editors. These are usually intended to demo small snippets of code that can be saved and shared. The feature sets of each service differ slightly, so you may need to try a few before you find the one that suits your specific requirements. Here are a few to get you started (with the most popular/fully-featured near the top). Many of these are based on CodeMirror or ACE.

jsFiddle – This is probably the most popular of these type of tools. It is pretty comprehensive and allows you to save and share your code. It includes HTML, CSS and JavaScript. You can choose from a wide range of pre-defined JavaScript frameworks, and you can also link to your own if it is not listed. It supports SCSS (Sass 3) and CoffeeScript if you are into those. You can choose from a variety of DTDs and modify the <body> tag (if needed). It has buttons for tidying up your code and JSLint support is included. The documentation is pretty comprehensive and the UI is nice and clean and easy to use. There is no code completion or code hinting as you type and your code doesn’t automatically run (you have to click the ‘Run’ button, or use the keyboard shortcut, to see your results). jsFiddle’s Twitter account is here.

JS Bin – This was created by Remy Sharp and is gaining in popularity. By default it has shortcuts to a huge list of JavaScript libraries, which you can include in your code. It supports many different flavours of HTML, CSS and JavaScript meta-languages (templating) like Markdown, Jade, LESS, Stylus, CoffeeScript, Processing, Traceur and TypeScript (Zen Coding is also supported). It has in in-built Console panel and the Output panel is automatically updated as you type. It automatically saves your code and there are a variety of sharing options. JavaScript error checking is provided via JSHint. A nice simple and clean tool, but again, no code completion or code hinting. A couple of great features it does have though is called Codecast (which enables people to watch as you type) and and Remote Rendering (which can be used to view your output on multiple devices in realtime). The documentation and help is pretty good too and the editor can be customised in great detail. Remy has done a fantastic job with this and he is always adding new and improved features. Follow JS Bin on Twitter.

Codepen – This tool was co-created by Mr CSS-Tricks (Chris Coyier) himself. It has a nice clean and well presented UI and the homepage is great for seeing other people’s demos (picked by the staff, or ranked as ‘popular’ or ‘recent’). The sharing and embedding options are good and forking other people’s projects is really easy (you can also see various Stats and Comments too). You can choose from a selection of colour schemes for the code editor (and select from three different fonts). Like jsFiddle and JS Bin, there is support for a variety of templating tools like HAML, Markdown, Slim, LESS, SCSS, SASS and CoffeeScript. It has built-in support for CSS Normalize, CSS Reset-prefix-free and Modernizr, and shortcuts to the latest versions of a few of the most popular JavaScript libraries. I think the strongest feature of this site is the way other people’s demos are showcased and easily accessible. This seems to be where all the cool kids hang out!

Dabblet – This tool was created by the very talented Lea Verou (who now works for the W3C), (check out her ‘Projects‘ page). This tool is focused on HTML and CSS (not JavaScript) and provides syntax highlighting and realtime updates. I particularly like the popup panels for CSS colors, gradients,  pixel dimensions, degrees and seconds. Plus the easy slider to increase the font size of the text in your code editor is handy. It has support for -prefix-free built in (it was created by Lea too) and is tightly integrated with github:gist. dabblet itself is open source and made available on github.

HTML5 Rocks Playground – This playground is really intended to show predefined examples of HTML5 code. You can’t use it to write your own snippets that can be saved and shared. But, for seeing how to do things (by the experts) in HTML, CSS, JavaScript this site is really great. Worth bookmarking.


jsdo.it is a Japanese online playground that has some very talented individuals using it. It is the sister site to the Flash AS3 online playground wonderfl. It pushes other peoples creations to the homepage (which is good for inspiration) and allows you to fork their code and modify it as you like. There are categories too (such as Application, User Interface, CSS, Game etc) which is useful. You can ‘Fav’ other peoples creations and you can ‘Follow’ them too (like you can on Codepen).

Tinkerbin – This editor has the basic features (separate panels for HTML, CSS, JavaScript and Output, but not resizable by dragging) and support for HAML, SCSS, SASS, LESS and CoffeeScript. You can save your snippets (each save is assigned it’s own unique short URL which you can pass on to other people) but it is pretty limited and doesn’t have some of the advanced features that jsFiddle, JS Bin and Codepen have.

Fiddle Salad – With this editor, you choose your coding style up-front. You are presented with the options of HTML (or HAML, Zen Coding, Markdown, CoffeeCup, Jade), CSS (or LESS, SCSS, SASS, Stylus), JavaScript (or CoffeeScript, Python, Roy), and then you hit the ‘Go’ button to start. The interface looks pretty busy (and not as clean as some of the other tolls listed above), but it does include a handy ‘Documentation’ panel which provides you with links to W3C’s CSS and HTML documentation, as well as jQuery (and the templating engines mentioned). Also, all the UI panels can be moved and resized which is pretty handy. Once you dig a little deeper you’ll realise that a lot of time and effort has gone into making this quite a fully featured tool. It has several different frameworks and libraries for you to choose from and select for import. It also has a number of ‘Tools’ such as validation and beautify tools (though some of these are just links to external websites). One thing that this has that some of the other tools don’t is code completion and code hinting (very useful in CSS). Overall I think this tool shows promise, but at the time of writing it doesn’t quite have the polish of jsFiddleJS Bin or Codepen.

ztxt – This is open source and available on github (thanks to Zevan Rosser). There is not a hosted version of this, the intention is that you download a copy of ztxt and then either run it locally using MAMP (or WAMP), or you host it on your own live webserver. I like the way that it can be used locally and allows access to your local filesystem. More information on ztxt can be seen on YouTube here.

Tinker – This is fairly bare-bones, but it does have a clean UI (with draggable editing areas) and offers syntax highlighting and saving (to a unique short URL). Clutter-free and to the point. It is open source and available to download from github (thanks to Chiel Kunkels).

CSS Desk – Created by Josh Pyles, this editor is for HTML and CSS only (no separate JavaScript). It has syntax highlighting, line numbers and realtime output. I like the fact that it allows you to easily save your edit out as a downloadable HTML file. You can save your snippet to a unique short URL for sharing. Minimal, but functional for CSS demos.

Liveweave – Created by Amit Sen, this tool requires you to have all your CSS and JavaScript in the HTML page (there is not separate panels like the other editors). It allows you to save your page as a downloadable HTML file which is handy. But for me, the killer feature (which most of the other editors don’t have) is auto-completion and code completion, a very useful addition (who can possibly remember all those CSS attributes and values?)

Cssizer – This tool (built by David Morrow) is also designed for HTML and CSS (not JavaScript) and has a limited feature set. However it does have syntax highlighting, realtime preview, and saving of snippets to a unique short URL (which get saved for you if you login using Twitter). You can also validate your code with an automated link to W3C. It is also open source and available to download from github.

pastebin.me – Created by Dale Harvey as a personal project, this tool is pretty bare-bones. A single editing panel with a non-realtime output panel. No syntax highlighting or features that the other editor have. It is available to download from github.

Html5Snippet – This is quite a slick editor with a number of saving and sharing features. I like the way you can download your code as separate files (.html .css .js) in a ZIP file. The editor also includes a huge list of predefined JavaScript frameworks and libraries. You can follow Html5Snippet on Twitter here.

Google Code Playground – This is similar to the HTML5 Rocks Playground, in that it is intended to demonstrate pre-written chunks of code (not as an editor for you to create your own and save) that you can tweak to see the results. The great thing about this is that it is chock-full of fantastic examples of accessing Google APIs, ranging from Google Translate and Google Calendar, through to Google Search, Maps and YouTube. If you are planning on using a Google API, it is worth checking here first to see if there is an example that will help. The link to the documentation is context sensitive, depending on what type of example you are viewing at the time.

TheCodePlayer – At the time of writing this site doesn’t allow you to create your own snippets and save them. But it does allow to play back the creation of their example HTML, CSS and JavaScript examples, which is very nice. It looks like in the future they are planning on opening the editor up for public use, to allow you to contribute your examples. I’d say ‘Keep an eye on this one’. Follow their Twitter stream here.

That pretty much wraps it up for now. I’m sure there are a bunch of other ones I’ve missed off this list (eg. Plunker), let me know in the comments if there is one I should take a look at. Enjoy!

Posted in CSS, HTML, HTML5, Javascript, Sample Code, Tool | 1 Comment »

Adobe Edge Web Fonts – Preview

October 3rd, 2012 by Adrian

Sample of the acme font

I have put together a webpage that previews all the (currently available) Adobe Edge Web Fonts.

You can view ALL the fonts here.

Note: The JavaScript may take a few seconds to load.

Posted in Adobe, Edge Animate, Fonts, HTML5, Javascript | No Comments »

swffit – Smart Flash Resize Script

February 5th, 2010 by Adrian

I remember stumbling across swffit ages ago, but never really gave it much thought at the time. However, a little while ago I put a small Flash site together (www.beauseat.com) for a friend, and it was scaled to fill the browser window. But when you resized the browser down to a small size you lost some of the navigation at the bottom. But today I re-found swffit, and it was just what I needed. It is really easy to use and just works!

Check out the swffit site and Google Code site

Thanks Miller Medeiros

Posted in Flash, HTML | 6 Comments »

Printing a PDF document from AIR without displaying it or the control bar (using PDF cross-scripting)

October 6th, 2009 by Adrian

Recently I had a project where I needed to allow the user to print out a PDF document from my AIR application, but I really didn’t need the user to actually view the document first and I didn’t want to display the default PDF control bar. I needed some way to send the PDF file to the printer directly from ActionScript. Enter PDF cross-scripting and Acrobat JavaScript. The following information should help you achieve the same result (note you need to have access to a copy of Adobe Acrobat Pro to add the JavaScript code to your PDF file).

There are several steps required for this to work …

  1. Open the PDF document you want to print in Adobe Acrobat Pro.
  2. Add the JavaScript code to your document and save it.
  3. Create an HTML page that contains a JavaScript function and embed the PDF document.
  4. In your Flash (or Flex) file add a button that prompts the user to print the document.
  5. Add the ActionScript 3.0 code that communicates with the HTML page you created in step 3.
  6. Publish your AIR file (making sure you include the HTML and PDF files).
  7. Test your AIR app.

Here is a copy of the PDF file I am printing in the following example.

Right, let’s explain each of the above steps in more detail.

Step 1

I presume you already have a PDF file prepared which you wish to print. Open this file up in Adobe Acrobat Pro. I’m pretty sure this works in version 7.0 and onwards.

Step 2

Open the ‘JavaScript Functions’ dialog box in Adobe Acrobat Pro by going to ‘Advanced’ > ‘Document Processing’ > ‘Document JavaScripts’.

Acrobat Document JavaScript Menu

Enter ‘myOnMessage’ in to the textfield and click on the ‘Add…’ button.

Acrobat JavaScript Functions

Then enter the following JavaScript code in to the window and click on the ‘OK’ button.

JavaScript Editor

function myOnMessage(aMessage)
      if (aMessage.length==1) {
                  case "Print":
                        //app.alert("Trying to print PDF");
                              bUI: true,
                              bSilent: false,
                              bShrinkToFit: true
                        app.alert("Unknown message: " + aMessage[0]);
            app.alert("Message from hostContainer: \n" + aMessage);

var msgHandlerObject = new Object();
msgHandlerObject.onMessage = myOnMessage;
msgHandlerObject.onError = myOnError;
msgHandlerObject.onDisclose = myOnDisclose;

function myOnDisclose(cURL,cDocumentURL)
      return true;

function myOnError(error, aMessage)

this.hostContainer.messageHandler = msgHandlerObject;

Then remember to re-save your PDF file.

Step 3

Create a blank HTML file and save it next to the PDF file. Then add the following code …

    <title>Load PDF</title>
        function callPdfFunctionFromJavascript(arg)
            pdfObject = document.getElementById("PDFObj");
            try {
            catch (e)
                alert( "Error: \n name = " + e.name + "\n message = " + e.message );
        <object id="PDFObj" data="document.pdf" type="application/pdf" width="800" height="600"/>

Step 4

For this example I’m using Flash CS3. Create a movieclip on stage that acts as a button prompting the user to print the PDF document. Give the button instance the name of ‘button’.

Step 5

In this example I have put all the ActionScript code into the document class. The code looks like this …

    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.html.HTMLLoader;
    import flash.html.HTMLPDFCapability;
    import flash.net.URLRequest;

    public class PrintPdfFromAir extends MovieClip
        private var _htmlLoader:HTMLLoader;

        public function PrintPdfFromAir():void
            button.mouseEnabled = false;
            button.alpha = 0.3;
            button.buttonMode = true;
            button.addEventListener(MouseEvent.CLICK, onButtonClick);
            trace("HTMLLoader.pdfCapability: "+HTMLLoader.pdfCapability);
            if (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) {
                _htmlLoader = new HTMLLoader();
                _htmlLoader.addEventListener(Event.COMPLETE, onHtmlLoader_COMPLETE);
                var urlRequest:URLRequest = new URLRequest("load_pdf.html");
        private function onHtmlLoader_COMPLETE(event:Event):void
            button.alpha = 1;
            button.mouseEnabled = true;
        private function onButtonClick(event:MouseEvent):void



Basically, we disable to button straight away and add a CLICK event listener. We then check the ‘HTMLLoader.pdfCapability’ property to see if the user has Adobe Reader 8.1 or greater installed on their system. If it equals ‘HTMLPDFCapability.STATUS_OK’ then we can continue. We then create a new instance of the HTMLLoader class, add a listener for the COMPLETE event. We then create an instance of the URLRequest class passing it the name of the HTML file we created in step 3. Next we call the ‘load’ method on our _htmlLoader instance, passing it the urlRequest instance. Then we add the _htmlLoader instance to the stage using addChild.

Normally, when you want to actually display the PDF file on screen, you also need to specify the width and height of the HTMLLoader instance. But in our case we don’t want to actually display it to the user. You may be wondering why we add it to the display list using addChild if we don’t want it to be visible. But I have found that it doesn’t work if you don’t add it to the display list. Not specifying the width and height also means it is not visible (which is what we want on this occasion).

Now we just have the two event handlers to write. The event handler for the HTMLLoader COMPLETE event just makes the button on screen active. We didn’t want the user to be able to click it before the COMPLETE event was fired.

The event handler for the button CLICK event calls the JavaScript function inside the HTML page, which we wrote in step 3.

Step 6

Now you are ready to publish the SWF file and then package it up as an AIR app in the usual way. The important thing to remember is to include the two external files (HTML and PDF) in the AIR Settings dialog box.

Include files

You can create a self-signed certificate for the purposes of testing. I have included my self-signed certificate with the source files (the password is ’1234′) which you can use if you wish, or you could just create a new one.

Step 7

Once you have exported your AIR file it is a good idea to test it on a few different computers to make sure it works properly. Try it on a machine that doesn’t have Adobe Reader installed, or one that has an older version (< 8.1).

Download example AIR app

Download the example AIR file

Click here to download the example AIR file

Download source files

Download ZIP file containing source files

You can download a ZIP file containing my example source files from here.

Useful links

Here are some other blog posts and articles I found useful …

Posted in ActionScript 3.0, AIR, Sample Code | 10 Comments »