AS3 CASALib Useful Library of Common Functions and Tools for Flash
When you do lots of any language you build up libraries over time that are time savers that are repetitive and tedious if you do not consoildate into a library. Taking a look at the CASALib, an as3 library of common functions for flash that was released I have many of the same things in my libraries but CASALib just has lots of extras that go a bit deeper than some libraries, is very clean and is organized pretty well.
One cool thing about it is the IDestroyable interface and the CasaMovieClip, CasaSprite, CasaTextField , etcthat all have a destroy() method that cleans up all events, removed instances and even removes it from the parent display object. Gets me thinking why this isn’t just part of DisplayObject in the first place.
From the release:
Here are a few of our favorite things in CASA Lib AS3:
- Standardized external load API
- Easily remove listeners with IRemovableEventDispatcher
destroymethods make garbage collection easy- Large group of utility classes for common manipulations
We will be elaborating further the power of CASA Lib in future blog posts.
As with any new release there will be bugs that emerge, but with your help we promise to release updates often to keep CASA Lib as stable as possible.
1.0.0 Downloads & Documentation
ZIP: http://as3.casalib.org/releases/1.0.0/1.0.0.zip
SVN: http://svn.as3.casalib.org/releases/1.0.0/
Documentation: http://as3.casalib.org/releases/1.0.0/docs/[source]
- AlignUtil
- Provides utility functions aligning DisplayObjects.
- ArguementTypeError
- ArrayContentsError
- ArrayUtil
- Utilities for sorting, searching and manipulating Arrays.
- AudioLoad
- Provides an easy and standardized way to load audio files.
- BaseLoadItem
- Base class used by load classes.
- CasaBitmap
- A base Bitmap that implements IRemovableEventDispatcher and IDestroyable.
- casalib
- Creates an easy way to determine what version/release of CASA is being used.
- CasaMovieClip
- A base MovieClip that implements IRemovableEventDispatcher and IDestroyable.
- CasaSprite
- A base Sprite that implements IRemovableEventDispatcher and IDestroyable.
- CasaTextField
- A base TextField that implements IRemovableEventDispatcher and IDestroyable.
- ColorUtil
- Provides utility functions for dealing with color.
- ConversionUtil
- Utilities for converting units.
- DataLoad
- Provides an easy and standardized way to load data.
- DateUtil
- Provides utility functions for formatting and manipulating
Dateobjects.
- Provides utility functions for formatting and manipulating
- Destroyable
- Base class for objects that are destroyable.
- Distribution
- Creates the mechanism to distribute DisplayObjects to a vertical or horzontal grid of columns and rows.
- DrawUtil
- Utilities for drawing shapes.
- Ellipse
- Stores position and size of an ellipse (circle or oval).
- EnterFrame
- Creates a centralized
enterFrameevent.
- Creates a centralized
- FlashVarUtil
- Utility for providing easy access to HTML embeded FlashVars.
- FrameDelay
- Creates a callback after one or more frames.
- FrameTime
- Creates a common time which isn’t affected by delays caused by code execution; the time is only updated every frame.
- FrameTimeStopwatch
- FrameUtil
- Utilities for determining label positions and adding and removing frame scripts.
- GeomUtil
- Utilities for positioning, calculating and manipulating geometeric shapes.
- GraphicLoad
- Provides an easy and standardized way to load images or SWF files.
- GroupLoad
- Allows multiple loads to be grouped and treated as one larger load.
- IDestroyable public interface
- IList public interface
- Interface for list collections.
- Inactivity
- Detects user inactivity by checking for a void in mouse movement and key presses.
- InactivityEvent
- An event dispatched from Inactivity.
- Interval
- To be used instead of
flash.utils.setIntervalandflash.utils.setTimeoutfunctions.
- To be used instead of
- IRemovableEventDispatcher public interface
- IResumable public interface
- IRunnable public interface
- Key
- Key class that simplifies listening to global key strokes and adds additional keyboard events.
- KeyCombo
- Class for storing keyboard key code combinations.
- KeyComboEvent
- List
- An ordered or sequence collection that can contain duplicates.
- ListenerManager
- Creates an easy way to implement IRemovableEventDispatcher when you cannot extend directly from RemovableEventDispatcher.
- LoadEvent
- An event dispatched during loading.
- LoadItem
- Base class used by load classes.
- LoadUtil
- Utilities for calculating a load’s speed and progress.
- LocationUtil
- Utilities for determining the location of the SWF and the type of runtime environment.
- NumberUtil
- Provides utility functions for manipulating numbers.
- ObjectUtil
- Utilities for working with Objects.
- Percent
- Creates a standardized way of describing and storing percentages.
- Point3d
- Stores location of a point in a three-dimensional coordinate system, where x represents the horizontal axis, y represents the vertical axis, z represents the axis that is vertically perpendicular to the x/y axis or depth.
- Process
- Base process class.
- ProcessEvent
- An event dispatched during a Process.
- ProcessGroup
- Manages and threads processes.
- PropertySetter
- Creates a setter function for properties.
- PropertyTween
- A simple property tween class that extends Tween.
- QueryStringUtil
- Utility for providing easy access to the browser query string.
- Range
- Creates a standardized way of describing and storing an extent of variation/a value range.
- RatioUtil
- Provides utility functions for ratio scaling.
- RemovableEventDispatcher
- Extends
EventDispatcherto allow for simple and quick removal of event listeners.
- Extends
- RetryEvent
- An event dispatched when a load request is retried after previously failing.
- ReversibleMovieClip
- Provides additional timeline controlling functions: reverse and gotoAndReverse.
- Sequence
- Creates a sequence of methods calls that wait for a specified event and/or delay.
- SequenceEvent
- An event dispatched from Sequence.
- StageReference
- Stores a reference to Stage for classes that cannot easily access it.
- Stopwatch
- Simple stopwatch class that records elapsed time in milliseconds.
- StringUtil
- Utilities for manipulating and searching Strings.
- TextFieldUtil
- Utilities for working with TextFields.
- Tween
- Simple and easily extendable tween/transition class.
- TweenEvent
- An event dispatched from Tween.
- UniqueList
- An ordered or sequence collection that contains no duplicates.
- ValidationUtil
- Utilities for validating common string formats.
- VideoInfoEvent
- An event dispatched when meta data, or cue point is received from the VideoLoad.
- VideoLoad
- Provides an easy and standardized way to load video files.
- VideoLoadEvent
- An event dispatched from VideoLoad.
Tags: ACTIONSCRIPT, ACTIONSCRIPT3, AS3, casalib, library, TOOLS, utility
![*drawlogic – interactive and game development technologies for the web – flash, flex, unity3d, silverlight, javascript [ draw.logic ]](http://farm4.static.flickr.com/3270/3068080918_eeebfbdb01_o.png)
Looks like a nice, helpful library! When looking at their code though again I’m wondering why so many programmers use tons of ‘this’ where it’s not necessary! It seems they don’t fully understand where and where not ‘this’ is actually needed. I’d say get rid of those damn ‘this’es where they aren’t needed!
Hey Sascha,
Yeh that actually really bothered me looking at the code. However there are some great ideas in the library that even the observance of the classes, even if you want to recreate them. The _ and the this references were not needed not my style but to each his/her own.
Thanks, it great news!
[...] CasaLib, een Actionscript 3 library met een grote verzameling handige functies CasaLib [...]
Hi Ryan,
Wanted to thank you for the write-up. I hope you and your readers find the library helpful.
Now for why I use ‘this’… A lot of people find it unnecessary, but we do it for clarity and to help with scoping. If you have a bunch of properties/variables in a large function you can easily tell if the variable is a temporary variable or a class level variable if it’s prefixed with ‘this’. It’s a readability thing. I know in a lot of cases it’s pretty clear, but we find it easier to uphold a constant rule then make cases for when it should or shouldn’t apply. Prefixing function calls with ‘this’ is also more of a consistency thing then anything else. But it does make it clear the method is part of the class and not an anonymous temp function.
Similarly with prefixing private or protected methods with an underscore. Seeing a method call you can instantly know if it’s private or protected, without searching for the declaration.
I know there are parties that feel strongly the opposite, but with the power of open source and a few find-and-replaces they can have their way.
I’d love any further feedback you or readers have directly, or on the CASA Lib discussion list.
Thanks,
Aaron
Hey Aaron,
On the this thing. Yeh I dont’ think it is an issue and it was clear that it was a clarification on scoping thing. It is somewhat like Python which I am fond of with self. Where that is required and is pythonic for as3 using this is probably not as widespread unless it is to differentiate from from a super or local.
In any case it is a quality library with great ideas thanks for making it and releasing it. Another cool thing about open source is you get your code reviewed. It helps to solidify your reasoning and maybe might change things who knows. I think the reason it was mentioned was just because it was not common in most AS3 standard code styles. There is a wide range of styles out there depending on where you come from. For instance box2dFlashAS3 is heavily c++ styled, still a quality kit.