Posted: April 20th, 2009 | Author: Jan Gorman | Filed under: Link | Tags: ActionScript, Flash, Portfolio | No Comments »
Last week saw the quiet relaunch of webwerk.de. I’ve been working on that for the last couple of months now, happy to finally see it go live.
Posted: March 4th, 2009 | Author: Jan Gorman | Filed under: Code | Tags: ActionScript, AS3, Code, Flash | No Comments »

Boy, I just learnt this the hard way (and after god knows how many years of developing in Flash..). Be careful when naming your TextField instances when placing them on the timeline. I called mine “name” since that’s what it is. First I only got a warning (which I dutifully ignored):
Error: Error #2078: The name property of a Timeline-placed object cannot be modified.
at flash.display::DisplayObject/set name()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
I could access this object on code fine, do everything with it but any other object placed on the timeline “after” this one simply returned a null pointer. What a nice way to spend a late afternoon.
Posted: February 9th, 2009 | Author: Jan Gorman | Filed under: Code | Tags: ActionScript, AS3, Code, Flash | No Comments »

Not having come across a solution to this on the web, I thought I’d share the one I came up with recently for a project I’m currently working on. There are several excellent articles that should get you up and running with the idea of custom events, here’s how to get them to talk.
First, you need your custom event:
package com.nickel.events
{
import flash.events.*;
public class ScreenResizeEvent extends Event
{
public static const DEFAULT_NAME:String = "com.nickel.events.ScreenResizeEvent";
public var ratio:Number;
public function ScreenResizeEvent( type:String, ratio:Number )
{
super( type );
this.ratio = ratio;
}
public override function clone():Event
{
return new ScreenResizeEvent( type, ratio );
}
}
}
Then you need a custom Event Dispatcher:
package com.nickel.events{
import flash.events.*;
import com.nickel.events.ScreenResizeEvent;
public class ScreenResizeDispatcher extends EventDispatcher
{
public function dispatchResize( ratio:Number )
{
dispatchEvent( new ScreenResizeEvent( Event.RESIZE, ratio ) );
}
}
}
And finally, you’ll need a class that holds static instances of your custom event dispatchers:
package com.nickel.events
{
import com.nickel.events.*;
public class Dispatcher
{
private static var screenResizeDispatcher:ScreenResizeDispatcher;
public static function getScreenResizeDispatcher():ScreenResizeDispatcher
{
if ( screenResizeDispatcher == null )
{
screenResizeDispatcher = new ScreenResizeDispatcher();
}
return screenResizeDispatcher;
}
}
}
This will allow you to do all kinds of funky stuff, any object that needs to listen to your events can do so like this:
Dispatcher.getScreenResizeDispatcher().addEventListener( Event.RESIZE, onResize );
And on the dispatching side, you can trigger your events like this:
Dispatcher.getScreenResizeDispatcher().dispatchResize( stage.stageWidth / IDEAL_SIZE );
So there you have it, hope it comes in handy to you.