Android – Events the easy (AS3) way

June 9th, 2009

I like the EventDispatcher class from ActionScript 3 so I decided to write one for Java.
Usage

1
2
3
4
5
6
7
foo.addEventListener("MyEvent", new EventListener() {
    public void run(Event event) {
        // remove the listener if no longer needed
        event.target.removeEventlistener(event.type, this);
        // do stuff
    }
}

Now your class can either extend EventDispatcherImp or implement EventDispatcher and you’re ready to dispatch events.

Via inheritance

1
2
3
import com.wumedia.events.EventDispatcher.EventDispatcherImpl;
public class Dispatcher extends EventDispatcherImpl {
}

Via composition

1
2
3
4
5
6
import com.wumedia.events.EventDispatcher.EventDispatcherImpl;
public class Dispatcher implements EventDispatcher {
    public Dispatcher() {
        _dispatcher = new EventDispatcherImpl(this);
    }
}

Read the rest of this entry »

Google Wave

May 31st, 2009

“Google Wave is a new tool for communication and collaboration on the web, coming later this year.”

but words don’t do it justice. You should watch the video for various demo of wave. I can see myself using my email, calendar and documents tools less and less… and eventually I can see wave replacing them for good. (if everybody gives up control to the all mighty google that is :) )
If there is something it doesn’t do, you can extend it by writing your own server bot or client side widget that will.

If you haven’t checked out Google Wave, you should at http://wave.google.com/

Extracting vector from SWFs, writing and now drawing with them

May 26th, 2009

******************** Update: ********************

There’s now a google project for this: code.google.com/p/swfvector. I’m going to be updating this so there might be some changes to the how the whole thing works.


I had a lot of positive feedback for my last project that lets you extract font glyphs out of a swf and write text using the flash drawing API or one of the popular 3D engines.

Now, this update fixes a couple of bugs and also adds support for any vector shape on the stage or the library.

Demo:

Get Adobe Flash player

Read the rest of this entry »

SWF file specifications

May 11th, 2009

If you’re interested in parsing or building your own SWF files.

here’s the file specification from Adobe,

http://www.adobe.com/devnet/swf/

Extracting font glyphs from SWF and Drawing with them

May 8th, 2009

UPDATE: please use newer and improved version at http://wu-media.com/2009/05/extracting-vector-from-swfs-writing-and-now-drawing-with-them/

Drawing text in flash using font glyph information is definitely not new. five3D does it, PV3D uses the five3D files to do it. and Michael Baczynski also did it.

So what’s so different with my approach?

I extract the font glyphs from your SWFs, so you don’t need to go through the extra step of creating a Class that has a bunch of arrays describing your font. You can now embed fonts just as you normally would, and the best part is… you can use the same fonts with regular TextFields which lowers your overall file size.

SWF files store fonts as a bunch of ShapeRecords the same way it does with graphics youd draw on the Stage in the Flash IDE. These ShapeRecords are composed of a bunched of lineTo, moveTo, curveTo and styles instructions. For fonts we only need the first three. since we’ll be doing they styling in code when we’re about to draw text our text.

Now that we’ve extracted these ShapeRecords. I’ve created a DynamicText class that draws on a Graphics target. This target can be

  1. the graphics property of a DisplayObject
  2. the graphics3D property of a Shape3D in five3D
  3. the graphics property of a VectorShape3D in PV3D

Sample code:

1
2
3
4
5
6
7
// extract font information from swf bytes
DynamicText.extractFontInformation(root.loaderInfo.bytes, true);
// set the style
graphics.beginGradientFill(GradientType.LINEAR, [0xff4400, 0x0], [1, 1], [0x00, 0xff], m);
// draw the ext
DynamicText.write(graphics, "Futura Md BT", 20, 20, 0, "Hello World");
graphics.endFill();

Flash DisplayObject.graphics draw sample:

Get Adobe Flash player

Read the rest of this entry »

Hello world!

May 5th, 2009

Welcome. I will use this space to post some experiments I do in my free time.