Feb 11 2009

Weird Loader event error after declaring RSS XML namespace

Can`t really get my head around this, I`ve used a code snippet from an Adobe RSS reader example to sort the namespace of an RSS feed:

if (rssXML.namespace("") != undefined)
{
default xml namespace = rssXML.namespace("");
}

Then tried to load an image using a URL from it with a listener for load completion:

var ldr:Loader = new Loader()
var url:String = item.enclosure.@url;
var urlReq:URLRequest = new URLRequest(url);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete)
ldr.load(urlReq);
contentHolder.addChild(ldr);>
public function onLoadComplete(event:Event):void
{
	trace(event)
}

But this kept on throwing me an annoying error:

ReferenceError: Error #1069: Property namespace not found on flash.events.Event and there is no default value.

Only solution was commenting out the namespace bit. It might work with a different namespace declaration, but not with this, so beware :)


Feb 2 2009

How to enable touch screen / stylus support in Adobe Device Central CS4

I recently got myself a shiny Nokia 5800, which to my knowledge is the first (mainstream) touch screen, Flash Lite (3.0) enabled phone. If you decide to create stuff for it and use Device Central CS4/CS3 to test it, soon enough you`ll realise that:

  1. Nokia 5800 is not in the online device library yet
  2. there`s no generic device with 360 * 640 resolution
  3. but most importantly you can`t use your mouse in Device Central.

This annoyed me to no end as I`m using a few fscommand2 directives, which when you sneakily try to test your content with Flash 7/8 profile will throw errors and won`t even let your .fla compile. So after some commenting/uncommenting these lines I`ve decided to look at the bottom of the problem :)

Enter duplicating and hand-editing .xml device profiles tucked away in your profile :)

For the daring, the single most important line to edit is this:

<mouseType value="None"/>

which should be set to:

<mouseType value="Stylus"/>

There are also 10s of instances of resolution to edit, so for the lazy types out there I`ve attached my freshly hacked custom profile to live with until Adobe/Nokia releases the official one. You have to download the .xml and put it to either of these folders depending your OS:

On Windows XP, the default location is:

C:\Documents and Settings\username\Local Settings\ApplicationData\Adobe\AdobeDevice Central CS4\Devices

On Windows Vista, the default location is:

C:\Users\username\AppData\Local\Adobe\Adobe Device Central CS4\Devices\

On Mac OS, the default location is:

user folder/Library/Application Support/Adobe/Adobe Device Central CS4/Devices/

Enjoy :)


Dec 11 2007

Custom cursor “bug” in ActionScript3

If you ever want to use a custom mouse cursor in AS3 (for say dragging) with rollover/rollout events toggling it (so it will only change the cursor for certain movie-clips), bear this in mind:
When the user moves the mouse to the right with a certain (slowish) speed, the (original) hidden mouse cursor will go over the custom cursor, so it will fire the rollout event. Then when Flash updates the custom cursor position, the original mouse cursor won`t be over the custom one anymore, so it fires the rollout event, thus the cursor blinks quite noticeably. And no, the event.updateAfterEvent() won`t help either.

The workaround for this is to add the MouseEvent.MOUSE_MOVE listener to the stage and watch the event.target in the handler function and toggle the custom cursor using that, so you can specify that Flash shouldn`t do the toggling (= keep the custom cursor on) when the mouse goes over it.

So it isn`t necessarily a Flash Player bug, because this behavior makes sense (the mouse updates much more frequently than the .swf), but well annoying to figure out anyway.


Dec 3 2007

Flash textfield height error using device fonts

I`ve ran into a rather annoying bug today, if you want to use either the _height or textHeight property of a textfield using device fonts and set to autoSize, it`ll add a phantom line, so will report the heights as if there was an extra line in the textfield.

The fix for it is quite random as well, you have to ADD a “\n” (=new line) at the end of your text and whooops, the phantom line is gone.