AS3 Indexed Object
Ever needed to create an object hash, yet wanted to retain some array functionality such as .length, and getItemAt()?
Well I wrote a handy little utuility class, using Proxy, that does so. Simply use it in place of a generic Object, and it will maintain a count of it’s properties, as well as allow you to reference any index you need
It also works with the standard for each, and for in loops commonly used with objects. So it’s basically plug and play, just replace:
var object:Object = {};
with
var object:IndexedObject = new IndexedObject();
and you’re good to go.
Public API:
length – returns the current length of your object
getItemAt(index:uint) – returns item at current index
removeItemAt(index:uint) – deletes item at current index
setItemAt(value:*, index:uint) – set item at specific index.
removeAll() – Guess :p
Performance:
I did some testing with adding new items and results were as follows:
Adding 10,000 items (with array access)
Generic Object: 40ms
IndexedObject: 70ms
Not too shabby, but could be better. In order to optimize it further, I added an option for when you only need the count, but don’t need to access elements by index. By passing false to your IndexedObject() constructor, it will only maintain a count and not a lookup array.
Adding 10,000 items (with no array access, just count)
Generic Object: 40ms
IndexedObject: 50ms
Not bad!
And finally, here’s the class
Note: I didn’t implement the entire Array API, slice(), concat, pop, etc etc, are missing. But are all quite trivial to add, so by all means feel free to add that functionality in if you need it.
Firefox 3 Scroll Wheel Fix
There a bug in Firefox 3 which causes the MOUSE_WHEEL event to always fire twice, no matter what. Here’s the fix…
FrameRate Monitor
Another utility class, this time a FrameRate monitor for easily getting the current frameRate of your movie.
ColorTween class
Here’s a very handy utility class to tween the tint of a MovieClip. It works by creating 2 color transform objects (based on a start and end color) and interpolates the colors in between. This uses GTween to handle the tweening of a dummy property, while the color is updated on the CHANGE event handler.
flipGallery 3D Source Code
This was pretty much my first real attempt at a PV3D project. Using an AS2 Cover Flow implementation as my target, I began redesigning it completely from scratch. The process was extremely enlightening, I learned a ton about both As3 and Papervsion, and I really think the end result is one of the best implementations I’ve seen. It’s extremely smooth, and able to handle upwards of 100 images with great performance.
Scrollbar Class (AS3)
Here’s a generic ScrollBar class, which will take a movieclip and create a scrollbar out of it.
The class accepts 2 parameters, your source movieclip, and the callBack function which should be notified whenever the Scroller’s position has changed. It also features some external interface to change the position of the scroller from somewhere else in your code
AS2 Inline Scroller
This scroller was written for an emergency situation at my last job, our 3rd party scroller from Extend Studios had a bug in in that caused the newest version of the Flash player to instantly crash our sites. This was a major problem, as we had already implemented about 35 sites using this plugin!
Shawnblais.com v2 is Live!
Well, after losing my Job on Tuesday, it’s been a mad scramble to develop a new website and get it up and running, so I can hopefully impress some potential employers..(not that my old site wasn’t cool…it was…like 8 years ago!).
The new site is up and I absolutely love it, yes it’s a bit slow on anything less than a Quad Core, and yes the nav is unusual, but I’m trying to do something a bit more forward thinking here, as well as flex my technical skills. I’m totally bored of the conventional website and navigation structure.
Also I do think that as 3D adoption grows, allowing users to config the site to match their system capabilities will become a more accepted approach, which is why I included some performance settings on the site itself. This is another thing that may rub some traditionalists the wrong way…
Obviously, the other new addition is this blog right here, stay tuned for many code examples and experiments in the future.
Thanks!