Skip to: Navigation Content Search


Archive for May, 2008

Starting out on my Flash journey (again) Saturday, May 24th, 2008

Now that the sun has come out and my employer’s training budget is large, I’ve decided to revist Flash and get my Actionscript skills up to scratch.

The last time I used Flash, as a naïve gen Xer looking to embrace the web, it was in version 2. Which sucked. But it was fun to fool around with things which, back then, were thought of as impossible to do with JavaScript and CSS alone such as smooth animation, timelines and pretty colours.

These days you can manipulate sound, images and video to such an extent that it’s made Flash the most ubiquitous piece of web software out there.

Not to mention that Flash skills are becoming more and more sought after from a Frontender.

So my quest starts with a very simple image gallery written nearly entirely in Actionscript (2.0 because we only have Flash 8 available to us at the moment) that reads the contents of an xml file.

The next step will be to write a class that builds thumbnails on the fly to an interactive thumbnail scroller for better browsing. At the moment you can only navigate left and right by hovering over the image itself.

It’s basic, but it’s a start for me back into the cool world of rich media.

Check out the simple image gallery.

Declaring functions in JavaScript Thursday, May 8th, 2008

Well, here’s a little tip for you if you didn’t know already. Some people say that there are a couple of ways of declaring functions in JavaScript and you can go to town doing one or the other (depending on your tastes) because they do precisely the same thing.

Well they do and they don’t.

Tell me why this will work:

<html>
<head>
   <script type="text/javascript">
    noodles();
    function noodles() {
      alert("Do you like noodles?");
   }
</script>
</head>
</html>


And not this:

<html>
<head>
   <script type="text/javascript">
    noodles();
   var noodles = function() {
      alert("Do you like noodles?");
   }
</script>
</head>
</html>


The second example will return our favourite word: undefined.

Maybe obvious to you, but not to me when I first got on the bandwagon. You see the browser will look at all function declarations (that is, the function in the first example) first and think, “Hey, these might be useful!” and then proceed to store them in a little hidey hole for use later. Then it will go on and do everything else. So when the browser encounters a call to a function it already knows what to do.

In the second example, we’re just assigning a function to a variable, which is great, but the browser has to know about it before we execute. In other words the execution must come after the variable declaration. It’s like trying to do this:

   alert(noodles);
   var noodles = "I love noodles!";

It’s just something to keep in mind.