Archive | November, 2005

Making Treeviews look good

18 Nov05

Just adding the finishing touches to our Flash based CMS named FlashPublish. One of the most important components is a treeview allowing you to drag and drop documents to reorganize your website quickly. I first used the Macromedia Treeview Component, but that really lacks a lot of the features I need. I then turned to my favorite component set from Ghostwire. It has a treeview that is really easy to use, but it doesn’t support drag and drop operations and it’s AS1 only. Finally I bought the dndTreeview for $29. Concidering that fairly low price and the possibilities it offers, it’s amazing.

As opposed to the Ghostwire components, the dndTreeview is just a class that extends the built in Treeview from Macromedia, adding all the stuff you’d need. The docs are a bit sketchy, but the email support is excellent. Just for future reference and for others to use. Here’s some tricks learned when working with it.

Being a coder, I have very limited drawing skills. FireWheel Design and their site IconBuffet can do wonders for the look of any application.

Adding Custom icons - Don’t use setIcon unless you need many different looking icons. Using styles are much easier and will set default styles for a full tree.

tree.setStyle('defaultLeafIcon', 'someIdentifier');

If you’re making something using special icons for each node, you may need this code:

private function setTreeIcons(x:XML,tree:Object) {
		for (var aNode:XMLNode = x.firstChild; aNode != null; aNode = aNode.nextSibling) {
			tree.setIcon(aNode,aNode.attributes.icon); // Sets the icon
			setIcons(aNode,tree); // Recurses into subnodes
		}
	}

This script will look for an “icon” attribute in the XML nodes and use this to attach linked symbols from your library as icons. Place this in your onLoad handler to start parsing:

setTreeIcons(this.firstChild,this.parent.imagetree);

Re-opening a treeview - Refreshing the datasource will collapse your treeview. I recently found a neat way to do this provided that the nodes have unique identifiers.

Instatiating the dndTreeview - The default way of instantiating a treeview is using createClassObject(dndTree,“my_tree”,this.getNextHighestDepth()); createClassObject is a method of mx.core.UIObject, so make sure your class extends this and not just the MovieClip class or you’ll get the error: “There is no method with the name ‘createClassObject’.” This is the clean way to do it since UIObject extends MovieClip.

See the future! Get Flash player 8.5 and Flex…

04 Nov05

Andre Michelle has been busy playing with AS3 lately. Thousands of pixels swarming across the screen just like in a MP3 vizualizer and a really fast raycasting engine This is something totally different than the first Wolfenstein copy! I had 30fps+ at 1024x768 pixels resolution! That’s speed!

I finally had an evening off from work (just crazy these days!) and installed the Flex 2 alpha along with the Flash 8.5 player. I didn’t want to install alpha-software on my primary machine so I’m using my gaming PC for this. Will start browsing Franto’s collection of AS3 samples next, but the speed of this alpha software is amazing! Andre’s sample with 150 balls collision testing plays back at 65fps with less than 1% CPU usage. WOW!
(Might even get an hour or two to play with Flex tomorrow if I’m lucky. Really looking forward to it!)

Flashy Halloween!

01 Nov05

pumpkin.jpgToday is Halloween. In case you didn’t dress up and visit the neighbours, here’s a treat for you: a very well done Interactive Pumpkin-thing.

I ran out of candy early this year. Seems there’s more and more kids every year. Halloween is an american tradition but kids everywhere grab the opportunity to get some extra candy - also in Norway where I live :)

Just saw JD linking to this story at CNN. While I do understand President Hugo Chavez’s concern, I must say that I feel that almost any excuse is a good one when it comes to candy (My fav movie this year by far).