Degrafa – states in non button classes

Application – Source

This post is to show how to use custom degrafa states in non button classes… say you want up, down, over states in a class… a button already does that for you, so in degrafa you just use the GraphicBorderSkin and create different states within it… very simple… and a lot of examples out there of how to do…  here are a couple of links to some blog posts that show how to do this.

Vixiom Post (actionscript example)

James Whittacker (mxml post)

What this post will show you how to do is, get those states in non button classes, like a canvas… say you want a canvas to have different states when you rollover and such… maybe you want to use it as a renderer…

I’m going to give credit where credit is due… all this codes is credited to my friend and co worker John Yanarella, he doesnt have a blog yet, and he just did this awesome stuff, and I wanted to be able to remember it… so I’m blogging on it… I fully asked his permission, and made sure he’s getting the credit… I didnt want to put the time into fixing the issue… so my round about solution was to put the degrafa right into the renderer instead of making it extend GraphicBorderSkin… his solution is far cleaner, and much more elegant than mine…

The key thing to look at is in the BoxItemRenderer, or CanvasItemRenderer, in updateDisplayList is setting the currentState to whatever it needs to be…

here is the code, and example

Application Source

Leave a comment