logo

Windows 8 start screen in HTML, CSS and Javascript
April 21, 2013 ~ Posted to CSS3, Experiments, HTML, HTML5, Interactive, Javascript, jQuery
win8

About 7 or 8 months ago I built a tile based launch page at work to launch learning modules which looked similar to the Windows 8 start screen. When I had spare time I kept building on and adding 3D animations to match it even closer to Windows 8. Then I kind of forgot about it until this week when I stumbled upon this article Creating Windows-8-like 3D animations with CSS3 and jQuery which provides a tutorial on creating a similar effect.

I had been meaning to do a post on my laucher when I first started making it but it never happened. So now that that article reminded me I thought I should post it. I am not going to provide any explanations of the code or tutorials but rather just show a demo (It’s HTML and javascript so you can just view the source anyway). I have ripped a bunch of LMS related code out of it and turned it into a web page launcher.

Click a tile to launch an ‘app’ (in this case a website). Hover you mouse over the top or bottom right corner for the ‘charms’ bar to close the site and return to the start screen. I have currently only tested it in Chrome and on an iPad and there isn’t a way to get to the charms bar on iPad yet.

Click to launch demo

21 APR


Getting all element attribute values with jQuery
April 20, 2013 ~ Posted to Javascript, jQuery
jqatts

Here is a little snippet which I have found extremely useful especially when working with XML in Javascript. You can use the following to loop through all of an element’s attributes and store them in an object:

var element = $("#myElement"),
    attributes = {};

$.each(element.get(0).attributes, function(i, attrib){
    attributes[attrib.name] = attrib.value;
});

So for example if we have the following XML node:

<item id="item1" name="the first item" image="thumbnail1.png" />

After running the snippet above on the node we can now access the values on the attributes object we created like so:

console.log( attributes.id ) // item1
console.log( attributes.name ) // the first item
console.log( attributes.image ) // thumbnail1.png

I have found this very useful when I don’t want to hard code XML parsing and I don’t need to know all the values right away.

I hope this is useful for someone else!

20 APR


Converting video with FFmpeg and Adobe AIR
February 4, 2013 ~ Posted to ActionScript, AIR, Flash, NativeProcess, Video
vc

Something I have been wanting to do for a while now is build a video converter into my Module Builder to enable automatic conversion of video into the various web friendly formats but I could never find a way to do it.

Over the weekend I discovered this tutorial on playing back any video in Adobe AIR. The tutorial runs through how to set up a NativeProcess to hook into FFmpeg to stream video from any format into FLV. FFmpeg is an open source media library for playback and conversion of almost any type of video or audio and is used by VLC and many other applications. I finally had a possible way of converting video within an AIR app! And one of the great things about this is since its using the NativeProcess API the conversion works asynchronously and the app doesn’t lock up while its converting.

Read More…

04 FEB


Inspiring Inspiration #10
January 30, 2013 ~ Posted to Inspiration, Interactive, Motion Graphics, User Interface, Video, Video Editing
ii10

A collection of cool video, motion graphics and interface design, mostly if not all from Vimeo…

Read More…

30 JAN


Uploading video from iPad to server with AIR for iOS
January 24, 2013 ~ Posted to ActionScript, AIR, Flash, Interactive, iOS, PHP
IMG_4719

In this part 2 post following on from Record and play back video with AIR for iOS on iPad I will show you how to take your freshly recorded video and upload it to a web server using PHP.

Assuming you have a MovieClip or some other button labeled ‘uploadbtn’ you first need to add a click event handler to it to trigger the upload.

uploadbtn.addEventListener(MouseEvent.CLICK, onUpload);

Now for the click handler:

function onUpload(e:MouseEvent):void
{
    // create a URLRequest for the PHP file on you server (we'll get to the PHP later)
    var URLrequest:URLRequest = new URLRequest("http://www.yourdomain.com/uploadFile.php");
   
    // videoFile is a File object we created in the last post which references the recorded video
    // attach the various listeners for errors, progress, complete
    videoFile.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadDataComplete);
    videoFile.addEventListener(ProgressEvent.PROGRESS, progressHandler);
    videoFile.addEventListener(IOErrorEvent.IO_ERROR, handleError);
    videoFile.addEventListener(Event.COMPLETE, completeHandler);
   
    // call upload on the File object and pass in the URLRequest
    videoFile.upload(URLrequest);
}

Now we can create the handlers for the attached listeners:

function progressHandler(e:ProgressEvent):void
{
    // just tracing the percentage of progress - you could show it in a progress bar
    trace("Uploading... " + Math.ceil(100 * (e.bytesLoaded / e.bytesTotal)) + "%");
}

function completeHandler(e:Event):void
{
    // upload process is complete
    trace(videoFile.name + " has been uploaded.\n");
}

function uploadDataComplete(e:DataEvent):void
{
    //everything is complete, trace the message returned from the PHP script which is in XML format
    var xml:XML = new XML(e.data);
   
    trace(xml.message);
}



function handleError(e:IOErrorEvent):void
{
    // simple error handler traces the error
    trace("Upload Error:" + e.text);
}

That is all that is required for the ActionScript side of things. Now for the PHP script. This is a very basic script and you should provide some security and validation on any production code.

All you need to do is save this into a blank PHP file and upload it to your server to the location matching the address in you URLRequest above.

<?php

// variable for return message
$message = "";

// the directory to place the video relative to this PHP script
$directory = "uploads/";

// get the number of files already in the directory and increment the number for the new one
// video from the iPad is always .MOV format
$fileCount = count (glob ($directory."*.MOV"));
$newName = $directory."video" . ( $fileCount + 1) . ".MOV";

// move uploaded file with new name into directory specified above
if (move_uploaded_file($_FILES["Filedata"]["tmp_name"], $newName)){
    // create a successful message if all went ok
    $message =  "<result><status>OK</status><message>$file_name uploaded successfully.</message></result>";
}else{
    // create a failed message if something went wrong
    $message =  "<result><status>FAIL</status><message>$file_name did not upload successfully.</message></result>";
}

echo $message;
?>

That is all that’s required to upload a video from the iPad to a web server. It is surprisingly simple for how hard it was for me to work out.

I hope this helps somebody out!

24 JAN


Virtual Graffiti Wall on Today in the US
January 23, 2013 ~ Posted to ActionScript, AIR, Flash, Interactive, Multitouch
vgwpix

Recently the Virtual Graffiti Wall application (formerly Pixel Perfect) I built for Classy Event Group was featured on the morning show Today in the US. Check out the 2 minute segment in the below video.

The app is built on Adobe AIR and is multi-user/multi-touch enabled. Features include:

  • Stencils (with rotate, move and scale)
  • Spray paint simulation with drips
  • ‘clip art’ stamps (with rotate move and scale)
  • Image gallery hot folder for live photobooth
  • Built in green screen removal with user fine adjustments
  • Customisable sounds for each brush
  • Saving and printing of artwork

The system is available for rental world wide at www.PhotoGraffitiWall.com.

23 JAN


AS3 – Split a camel case string
January 19, 2013 ~ Posted to ActionScript, Flash
shutterstock_112149554

This is a little helper function which takes a string in camel case (camelCase) or pascal case (PascalCase) and splits it into separate words. The capitaliseFirst parameter will capitalise the first character in the first word if the string is in camel case.

Read More…

19 JAN


Record and play back video with AIR for iOS on iPad
December 3, 2012 ~ Posted to ActionScript, AIR, Flash, iOS, StageVideo
IMG_4720

Recently I needed to figure out how to create an iPad app when you can record and play back video from the iPad’s camera, and then upload to it to a server using AIR for iOS. I wasn’t able to find a whole lot of info on it and so I eventually pieced it together from various places. I decided to share the first part of the process here, and I might share the second part in another post later.

I will assume you have a button on the Flash stage called ‘recordbtn’ which the code below will use to fire up the device’s camera.

First we have to set up some variables and check for StageVideo availability:

// use stage video to playback recording
var stageVid:StageVideo;

// variables for displaying the video
var videoFile:File;
var ns:NetStream;
var nc:NetConnection;

// create instance of CameraUI for showing native camera app
var deviceCameraApp = new CameraUI();

// we'll use StageVideo to display the recorded video, first we have to listen for availability
stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onStageVideoAvailability);


function onStageVideoAvailability(e:StageVideoAvailabilityEvent):void
{
    // if StageVideo available
    if (e.availability == StageVideoAvailability.AVAILABLE)
    {
        // get stage video instance
        stageVid = stage.stageVideos[0];

        // create a net connection for playing back the video
        nc = new NetConnection();
        nc.connect(null);
       
        // create a netstream for the net connection       
        ns = new NetStream(nc);
        ns.client = this;
       
        // add click event to record button
        recordbtn.addEventListener(MouseEvent.CLICK, onRecord);
       
        // add event for stage video render state
        stageVid.addEventListener(StageVideoEvent.RENDER_STATE, onRender);
    }
   
}

function onRender(e:StageVideoEvent):void
{
    // when the video is ready to play set the viewport size so we can see the video
    stageVid.viewPort = new Rectangle( 247 , 43 , 529 , 397 ) ;
}

Read More…

03 DEC


AS3 / JS Constrain a value in one line
November 29, 2012 ~ Posted to ActionScript, Javascript
const

Here is a little snippet to constrain a value in a single line. It works by using two nested inline conditionals. The ‘else’ part of the first conditional is another conditional. It may not be the best approach but it works and is much easier and faster to write than two if-else statements.

In English it looks like this:
value = is value greater than max ? set to max, otherwise is value less than min ? set to min, otherwise leave it as is;

// for js - remove the type declarations (:Number)
var minValue:Number = 0;
var maxValue:Number = 100;

value = value > maxValue ? maxValue : (value < minValue ? minValue : value);

29 NOV

Older Posts »