Dynamic Flash

Confessions of a serial code abuser
  • rss
  • Home
  • MTASC
  • Archives
  • About me
  • Goodies
    • Base64 encoder/decoder class
  • My Bookshelf
  • My Talks

<head> over heels

Wednesday, 29 October 2008

So, <head> 2008 is over, and it was nothing short of amazing. Sure, there were a few technical issues, but that’s inevitable when you’re bringing together 70+ speakers and over 2000 attendees from all over the world into one virtual online space for 3 days of fun and learning.

I was fortunate enough to take part in two sessions at the conference. The first was a “State of Flash” conversation live on stage at the London Hub with Carlos Ulloa and Seb Lee-Delisle, and with Aral Balkan guest-starring as moderator. This was my first time on stage at a proper conference, and I think the conversation format and sharing the stage with 3 Flash luminaries, not to mention the large Yahoo contingent in the audience, really helped to ease whatever pre-session nerves I had.

We covered a whole bunch of Flash related topics, from what excites us in the Flash world to discussion of Johnathan Harris’s controversial statements made during the closing keynote at Flash on the Beach ‘08. Based on the questions and feedback afterwards, it seems this session went down pretty well.

Steve Webser, Carlos Ulloa and Seb Lee-Delisle in conversation on stage at head (Photo: bru76)

Steve Webser, Carlos Ulloa and Seb Lee-Delisle at <head> (via bru76)

The second session, entitled Beg, Borrow or Steal: The Art of Flashing Without Flashing, was presented virtually from the comfort of my own living room on Sunday evening. The basic idea was to show that you can steal advanced features from the Flash Player in your standards-based sites and applications that you would otherwise have to wait until HTML5 is fully supported to use. Every time I practiced this before the day the session came in at around the 25 minute mark. Somehow, on the day, I managed to tak up 40 of my allotted 45 minutes with the slides and examples, which only left 5 minutes for Q&A. Oops.

Anyway, the slides and example files from the second session are available to download from the My Talks section of this site. Eventually there will be videos of both sessions available through the <head> website, though for the first 6 months they are exclusive to attendees of the conference. I’ll post a follow-up once the videos are generally available.

A massive thank-you goes out to Aral and the rest of the <head> team for putting together such an awesome and groundbreaking conference. Friday’s sessions and the general geek gathering at the London hub were, in my opinion, worth the admission price alone, and being able to watch the remainder of the conference in my pajamas was quite an experience. One thing’s for sure: <head> ‘09 has a lot to live up to.

Comments
1 Comment »
Categories
General
Tags
ActionScript, Flash, head, head08, head2008, headconference, html5, JavaScript
Comments rss Comments rss
Trackback Trackback

I am Singularity

Friday, 08 February 2008

Singularity?

Aral has finally taken the wraps off of his super-secret Singularity project:

Singularity is the first large-scale online web conference in the world. Singularity is over 100 of the world’s top web visionaries, developers, designers, thought leaders, and celebrities. Singularity is three days of talks over multiple tracks. In 2008, Singularity will define Web ‘08.

I’m proud to say that I’ve signed up as a speaker for the event. My session, however, is an absolute secret that I will not divulge to anyone before the time is right. Okay, okay… I’m not 100% sure what my session is going to be just yet, but I’ve got until mid-october to sort something out. My experience working at Yahoo! – trying to bring together the best from the Flash/Flex work with the best from the HTML/CSS/JS standards world – is sure to give me a unique view on something, right?

If there’s something specific you want to hear about, let me know via the comments.

Comments
1 Comment »
Categories
ActionScript, Flash, Flex 2, Flex 3, Open Source
Tags
ActionScript, conference, Flash, flex, singularity08
Comments rss Comments rss
Trackback Trackback

FileReference.upload doesn’t support custom headers

Monday, 14 January 2008

At work we’re working on an application that makes heavy use of the FileReference.upload() method to upload files to the server. We recently had a change request to add some custom HTTP headers to the upload request, which I didn’t think would be a problem. I was wrong.

When using the FileReference.upload() method to upload a file to a server, you can specify additional variables to be sent along with that upload request by means of a URLRequest object like so:

// Create new request object and point it at the right URL
var request:URLRequest = new URLRequest();
request.url = "/upload.php";
 
// Specify additional variables to be sent with request as POST data
request.method = URLRequestMethod.POST;
request.data = new URLVariables();
request.data.foo = "bar";
 
// Upload file using data from request object
fileRef.upload(request);

Since you can send custom headers using the URLRequest object’s requestHeaders property, I should have been able to specify custom headers for my file upload request fairly easily:

// Create new request object and point it at the right URL
var request:URLRequest = new URLRequest();
request.url = "/upload.php";
 
// Specify additional variables to be sent with request as POST data
request.method = URLRequestMethod.POST;
request.data = new URLVariables();
request.data.foo = "bar";
 
// Specify additional headers to be sent with request
var header:URLRequestHeader = new URLRequestHeader('X-Test-Header', 'Hello');
request.requestHeaders.push(header);
 
// Upload file using data from request object
fileRef.upload(request);

Sadly, the above code doesn’t work. I checked the raw request and response using Charles and the custom X-Test-Header I was trying to send just wasn’t coming through. I tried a number of different variations of the same code, all with the same result.

The problem, I have just discovered, is that there are a number of restrictions placed on the URLRequest object when used in conjunction with the FileReference methods. One of these restrictions is that the requestHeaders property is completely ignored when using the FileReference.upload() method, so it’s impossible to send custom HTTP headers along with a file upload.

To be completely fair to Adobe, this and the other restrictions are stated quite clearly in the documentation for the URLRequest object:

The FileReference.upload() and FileReference.download() methods do not support the URLRequest.requestHeaders parameter.

Since I can’t see any security or technical reason why the URLRequest object should be restricted in this way, I’m off to file a bug with Adobe to see if we can get this addressed in a future version of the Flash Player.

Lesson learned: RTFM.

Comments
8 Comments »
Categories
ActionScript, Flash, Flex 2, Flex 3
Tags
ActionScript, air, file upload, filereference, Flash, flex, urlrequest
Comments rss Comments rss
Trackback Trackback

Foundation ActionScript 3.0 now available

Sunday, 13 January 2008

Foundation ActionScript 3.0 with Flash CS3 and Flex

Somehow this slipped under my radar, but better late than never. Foundation ActionScript 3.0 for Flash CS3 and Flex, my big book-writing project from last year, is now available in all good bookshops.

Here’s some of the blurb from Amazon.com:

Whether you are an aspiring ActionScript developer, or an experienced ActionScript developer who wants to upgrade your knowledge to version 3.0, this book teaches all you need to know to start to harness the power of ActionScript 3.0 using Flash CS3, Flex 2 or Flex 3. It covers all the essential techniques from the ground up, allowing you to get up and running quickly and easily.

The book is available to purchase right now at Amazon.com and Amazon.co.uk and all good bookshops.

Comments
6 Comments »
Categories
ActionScript, Books, Flash, Flex 2
Tags
ActionScript, actionscript 3.0, book, designer, Flash, flex
Comments rss Comments rss
Trackback Trackback

ClassFinder class

Thursday, 10 March 2005

In a recent project I needed to instantiate a number of objects of various classes based on configuration data coming from an XML file. Unfortunately instantiating a class at runtime is not straight forward if all you’ve got to work with is a string. What I needed was some way of getting a reference to the constructor function of a class given the fully qualified class name. Ten minutes of tinkering later, I came up with the ClassFinder class.

class com.dynamicflash.utils.ClassFinder {
  public static function find(package:String) : Function {
    var packageParts:Array = package.split(".")
    var obj:Object = _global;
 
    for (var i:Number = 0; i < packageParts.length; i++) {
      obj = obj[packageParts[i]];
    }
 
    return Function(obj);
  }
}

Feeding the ClassFinder.find() method with a fully qualified class name will return a reference to the constructor of the class. You can use this to instantiate an object of that class using new and passing any arguments to the constructor as you would normally.

import com.dynamicflash.utils.ClassFinder;
 
var myClass:Function = ClassFinder.find("com.dynamicflash.SomeClass");
 
var instance = new myClass("Test");

Classes are stored in _global with nested objects representing the package hierarchy. All ClassFinder.find() does is split the package name into chunks and descent the nested objects one at a time to find the class constructor function.

So what’s the catch? Because of the way the Flash compiler works, any classes that aren’t explicitly referenced in any of your code at compile time will not be included in the SWF. This means that ClassFinder won’t be able to find them, returning undefined instead. If you want to trick the compiler into including such classes, you need to make a dependancy link to those classes from a class that is explicitly referenced in your code.

class com.dynamicflash.SomeOtherClass {
  public function SomeOtherClass () {
    ...
  }
 
  // Create dependancy link
  private static var SomeClassDependancy = com.dynamicflash.SomeClass;
}

This method is used in Macromedia’s V2 component core classes to make sure they’re all included in the SWF if just one of them is referenced.

–Update–

I’ve just realised that a very similar class is included with Flash MX 2004 Professional, but adding it to your projects isn’t exactly intuitive. You have to open up the Classes common library (via Window » Other panels » Common libraries » Classes in the main menu) and drag the UtilsClasses symbol into your library. You can then use mx.utils.ClassFinder.findClass() instead of my class.

Why Macromedia didn’t just put these classes in the standard folder I don’t know, but since using it requires extra work I’ll stick with my version of ClassFinder.

Comments
11 Comments »
Categories
Flash
Tags
ActionScript, Flash, reflection
Comments rss Comments rss
Trackback Trackback

« Previous Entries

About Dynamic Flash

Steve Webster is a Senior Web Developer for Yahoo! in London, UK.

He is more than a little concerned that he defines himself in terms of his career, and that he talks about himself in the third person.

Find out more

del.icio.us-ed

  • samuel's squawk at master - GitHub
  • Pixelwave - A native 2D iPhone framework, based on the Flash API
  • Pixelwave - A native 2D iPhone framework, based on the Flash API
  • mnot’s Weblog: Are Resource Packages a Good Idea?
  • Download details: IE App Compat VHD
  • ZSync
  • jQuery source viewer
  • Penetration testing tools - Stack Overflow
  • Logrep
  • DOM Window (jquery.DOMWindow.js)

Recent Posts

  • Moving on
  • iPhone / iPod Touch Development Resources
  • Upgrading your app to AIR 1.5
  • Motivate yourself by doing it in public
  • The trouble with Flash and REST
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox