assertTrue is the professional blog of Luke Bayes and Ali Mills

HaXe 1.06 :: Flash 7/8 Library Assets in Flash 9

Posted by: Ali Mills Tue, 29 Aug 2006 05:48:00 GMT

Before I’ve even had a chance to experiment with haXe 1.05, verison 1.06 has been released! How long did that take? Maybe a week? Two of the more interesting features of this version are that it supports the use of Flash 7/8 library assets from Flash 9 code and there’s been an addition of a RubyGems like distribution system called haxelib.

You can read about all of the new features and Nicolas’ blog, but here’s a quick glance at the change log:

  • allowed extern enums
  • use only matching construct when parameters are matched
  • fixed bug preventing & char to be sent between JS and Flash remoting
  • improved flash9 api (more strict)
  • flash9 xml : use JS ReXml parser
  • added neko.io package (Input/Output)
  • moved neko.File and neko.Socket to neko.io package
  • fixed flash optional arguments (when extending flash.MC)
  • fixed neko native serialization problems
  • variable modification does not have side effects in ‘for x in a…b’
  • jit disabled by default for neko web server
  • enable flash7-8 libraries usage from flash9
  • unknown identifier become “class not found” when is a classpath
  • changed haxe.PosInfos handling
  • added -debug (removed—flash-debug) on flash9 and neko only now
  • added Type.typeof
  • improved Serializer speed
  • added Serialization support for Date, Hash, IntHash, List
  • added flash9 and JS IE/Opera class reflection
  • added haxe.xml.Check and haxe.xml.Fast
  • added Xml.parent
  • added haxelib
  • added ArrayAccess interface

As always, you can download the latest build from http://www.haxe.org/download.

Tags  | no comments

HaXe Sample Application :: Simple Slide Show

Posted by: Ali Mills Tue, 22 Aug 2006 05:15:00 GMT

If you’ve been reading this blog then it should be clear to you that I’m pretty interested in the haXe programming language (if it’s not clear see: Invest Regulary in Your Knowledge Portfolio, Where’s haXe?, HaXe Found!, and HaXe 1.05 Supports Flash Player 9!). My interest in haXe is rooted in my desire to build universally available applications with a code-base that I can grow.

To learn the haXe syntax and language APIs, I wrote a Simple Slide Show application that I call Mediator. Here it is:

You can download the source here.

Some interesting parts of Mediator follow:
  • the EventDispatcher class demonstrates many elements of the haXe syntax
  • background art is externalized in the FLA art/MediatorAssets.fla
  • slide data is externalized in the XML document xml/Mediator.xml
  • the MediatorModel class demonstrates XML parsing in haXe
  • the entire application has a flexible layout (which you won’t be able to notice unless you download Mediator.zip, run the Mediator.swf on your desktop, and resize it)
  • Events in the application bubble, this is handled by the Component class’s dispatchEvent() method; that method looks like:
    public function dispatchEvent(event:Event):Bool {
        var dispatched:Bool = dispatcher.dispatchEvent(event);
        if(event.bubbles && dispatched && getParent() != null) {
            getParent().dispatchEvent(event);
        }
        return dispatched;
    }

To compile the simple slide show, first download and install haXe, then download Mediator.zip, and after unpacking it double-click build.hxml.

To run the application locally without compiling, just double-click Mediator.swf.

Tags ,  | no comments

HaXe 1.05 Supports Flash Player 9!

Posted by: Ali Mills Thu, 17 Aug 2006 20:58:00 GMT

I just noticed that haXe 1.05 was released yesterday, and it now supports publishing to Flash Player 9. I’m impressed. Nicolas (of MTASC, the first ActionScript 2 Open Source free compiler fame) is a super-coder.

I haven’t tried publishing a Flash Player 9 SWF yet, but I will soon. Here are some haXe links:

Tags ,  | no comments

HaXe Found!

Posted by: Ali Mills Tue, 08 Aug 2006 04:35:00 GMT

In comments to the last post Where’s haXe?, iongion did a great job spotting many of the ways in which haXe differs from ActionScript 2.0. Highlights of the differences in syntax follow:


package mediator.events;

In haXe, source code files can begin with an optional package declaration. The files should exist in subdirectories mapping to the package declaration.


    private var listeners:Array<EventListener>;

HaXe uses typed arrays. In the code snippet above, the type parameter <EventListener> means that the listeners array contains objects of type EventListener.

Read more...

Tags  | no comments

Where's haXe?

Posted by: Ali Mills Wed, 02 Aug 2006 07:30:00 GMT

The code below may look like ActionScript, but it’s not. It’s haXe. Can you spot the differences?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package mediator.events;

import mediator.events.Event;
import mediator.events.EventListener;

class EventDispatcher {
    private var listeners:Array<EventListener>;
    private var eventTarget:Dynamic;

    public function new(?eventTarget:Dynamic) {
        listeners = new Array();
        if(eventTarget) this.eventTarget = eventTarget else this.eventTarget = this; 
    }

    public function addEventListener(type:EventType, handler:Dynamic, context:Dynamic):Void {
        removeEventListener(type, handler, context);
        listeners.push(new EventListener(type, handler, context));
    }

    public function removeEventListener(type:EventType, handler:Dynamic, context:Dynamic):EventListener {
        var listener:EventListener = new EventListener(type, handler, context);
        for(i in 0...listeners.length) {
            if(listeners[i].equals(listener)) {
                return listeners.splice(i, 1)[0];
            }
        }
        return null;
    }

    public function dispatchEvent(event:Event):Bool {
        var type:EventType = event.type;
        var listener:EventListener;
        untyped {event["target"] = eventTarget;}
        for(i in 0...listeners.length) {
            listener = listeners[i];
            if(listener.type == type) {
                Reflect.callMethod(listener.context, listener.handler, [event]);
            }
        }
        return true;
    }
}

Tags  | 2 comments

Invest Regulary in Your Knowledge Portfolio

Posted by: Ali Mills Wed, 26 Jul 2006 06:30:00 GMT

I must have learned something from the first chapter of The Pragmatic Programmer by Dave Thomas (who’s probably better known these days for his contributions to the Ruby community through his publishing company and must-have book Programming Ruby) when I read it long ago. In that chapter, Dave’s 8th tip is to, “Invest Regulary in Your Knowledge Portfolio”. One of the ways he suggests doing so is to learn one new language a year. Well, this year I seem to be making up for years gone by, because I’ve been spending a lot of my extra time working with several different languages and their frameworks. This year, I’ve been working with – in order as of today – haXe, Flash Lite 1.1, Ruby, ActionScript 3.0, XUL, and the Nullsoft Scriptable Install System. I’ve been working with their frameworks Ruby on Rails, Flex, and XULRunner.

All of these languages are tools to build the kind of software that I’m interested in building: software that’s fun to write, easy to distribute, a pleasure to use, useful, and affordable. For software to be distributed easily and a pleasure to use has to be universally available. And, to be universally available it needs to be truely cross-platform – cross-software and cross-hardware. It needs to work on win, mac, and nix and also in a browser, on a desktop, and on a palmtop. Today, the best format to make software universally available is the SWF format. It’s undeniable, more people have the Flash Player than any other piece of software .

It is, granted, worth noting that some feel like traditional Java, non-traditional Java, Python, Ruby, .NET, and the Mozilla Foundation’s XUL are also acceptable tools to make available software, and depending on the goal, they’re correct. In many cases, these technologies can even enhance a SWF’s funcionality. For example, it’s possible to use Mozilla’s XULRunner as a desktop wrapper for SWFs, or if you’re really smart, to do what Rich Kilmer did and write a SWF view to a Ruby controller and Berkeley DB model. Rich gave me and Luke a sneak peak at his indi product at RailsConf, and we were blown away. The product is a great idea, and it’s built on an extremely smart and interesting architecture. Get indi when it’s available.

Invest regularly in your knowledge portfolio.

Tags , , , , , , , , ,  | no comments