Archive | February, 2009

Flash MP3 player for JavaScript

26 Feb

I recently got a request from a friend that’s a JavaScript developer and he needed to play some sound effects in an an app he’s working on and he asked me for advice. I quickly made a headless SWF that can play, pause and stop any online MP3 file from JavaScript and I figured that others might also be interested in this so I’m posting it here for others to grab.

Bare bones example - SWF file  - Actionscript class - FLA file

PS: if you use this, send me an URL so I can link to it?

Actionscript syntax highlighter

26 Feb

Due to a limitation in EE I had to change all the Flashmag tutorial code from using <pre> to <code> tags and figured I’d add some nice syntax highlighting while at it. After checking a few, I found SyntaxHighlighter 2.0 that looked clever. Only one problem - they didn’t have a syntax file for Actionscript, so now I’ve made one and you can see it in action here (scroll down to the code listing). You can pop up a nonformatted version, copy straight to clipboard (via a small shim SWF file and print. Nifty, isn’t it?

I initially figured that I wanted all AS3 classes/datatypes to highlight as well, but that was a little too ambitious smile  The AS3 core language with all AIR and Flex extensions amounts to more than 950 classes! Just the class names make up 14Kb so I rather settled for a lightweight version that only highlights the classes you’ll use the most such as arrays, booleans, sprites and more.

If you want to add this to your own site, download the .js file (lightweight version/full API version) and here for the .css file. You’ll also need to download the SyntaxHighlighter files.

Installing is just a matter of copying the files to the server and adding a few lines to your templates. Here’s what I’ve added to the header on this site:

	<script type="text/javascript" src="/js/shCore.js"></script>
	<script type="text/javascript" src="/js/shBrushAScript.js"></script>
	<link type="text/css" rel="stylesheet" href="/js/styles/shCore.css"/>
	<link type="text/css" rel="stylesheet" href="/js/styles/shThemeActionscript.css"/>
	<script type="text/javascript">
		SyntaxHighlighter.config.clipboardSwf = '/js/clipboard.swf';

On Flashmag, I’ve also changed from using the default <pre> tag to <code> by adding this line:

SyntaxHighlighter.config.tagName = "code";

Flash and IE6 bug when loading XML

07 Feb

Last week I stumbled upon a really odd Flash Player bug. I’d done a project for a client that loaded XML. It worked great on the clients test-server, but when moved to the deployment server we got a weird error - in Internet Explorer 6, the XML refused to load, returning an IOError?

When I debugged I found that the Flash Player was indeed loading the XML but it apparently failed to parse it? After some Googling I found this article at MediaCatalyst that claimed that this had to do with the headers sent from the servers? Didn’t really sound probable, but it was worth a shot. It worked…? Wow. Somebody should fix this bug, shouldn’t they?

So - if you’re having problems loading XML with only IE6, make sure you check that the server does not send the HTTP response header: Cache-Control: no-cache You can easily check this using a tool like Charles.

Luckily, IE6 is less and less popular and with some luck, web designers can stop worring about it in a year or two.

Is Flash 3D a toy or a tool?

04 Feb

Yesterday I delivered a talk at the first Norwegian FlexCamp here in Oslo. My session topic was “Realtime 3D on the web - toy or a useful tool?” and it went down really well. I discussed why 3D on the web never got popular and what “Good use of 3D” could be. It’s a little hard to find good use cases if you don’t include the obvious things such as games, product presentations and experimental interfaces, but if you have good examples - please post it in the comments?

I showed 5 projects I’ve made that I think makes good use of 3D and I got lots of nice feedback. As promised, here’s the link to my presentation. The presentation is in Norwegian, but I’ll also do something similar for my session at the FlashForum Conference in Cologne in April and that session will be in English. At FFK09 I’ll also do a full day workshop on Away3D so if you want to get started with 3D in Flash, this could be a good start.


Today also marks the beta launch of my first public facing 3D application, a 3D StreetView covering the Oslo area. Click the blue dots in the map to view a location. There’s more than 120.000 panoramas in total, so you can see pretty much every part of Oslo. Go check it out!