CASA Lib AS3 Release 1.3.0

Written by Aaron Clinger on March 29th, 2010

It took longer than expected, but there is finally a new release of CASA Lib for AS3. This release adds stability, improvements and a lot of great new features. Some of my favorite changes are the new class LoadItemUtil which creates a CASA load item based on the file path, the additions to GroupLoad to make it more versatile and the modifications to AlignUtil and Distrubution to use DisplayObjectUtil‘s new getOffsetPosition method to be able to properly align DisplayObjects that have been scaled or whose registration point is not at 0, 0.

This release and all future releases will include a SWC archive file along with the full class source for those who prefer SWCs over class libraries.

Update: If you are compiling with MXMLC and getting an error please read about the compiler bug: 1047 Compiler Error with AS3 1.3.0.

Change Log

  • Added CasaShape.
  • Added LoadItemUtil with a createLoadItem method. The method takes in a file path and returns the correct CASA load type.
  • Added UrlVariablesUtil class which contains an alphabetize method for sorting URLVariables.
  • Added align, alignToPixel & alignRectangle and convenience methods alignBottomCenter, alignBottomLeft, alignBottomRight, alignMiddleLeft, alignMiddleRight, alignTopCenter, alignTopLeft & alignTopRight to AlignUtil.
  • Added autoLink to StringUtil which detects URLs in a String and wraps them in a link.
  • Added method truncate to StringUtil.
  • Added uuid and createRandomIdentifier to StringUtil.
  • Added drawPath and drawShape to DrawUtil.
  • Added errored getter to LoadItem which can be used to determine if the load could not complete due to an error.
  • Added getOffsetPosition to DisplayObjectUtil. The offset can be used to position DisplayObjects whose registration point is not at 0, 0 and/or is scaled.
  • Added method getChildren to DisplayObjectUtil.
  • Added getTotalEventListeners to RemovableEventDispatcher and all event classes.
  • Added getValuesByKey, getItemByKeys, getItemsByKeys, getItemByAnyKey and getItemsByAnyKey to ArrayUtil.
  • Added recursive parameter to destroyProcesses in ProcessGroup and destroyLoads in GroupLoad.
  • Added a stop() in the destroy method of CasaMovieClip to avoid any lingering garbage collection issues.
  • Added a recursive option to ProcessGroup‘s hasProcess.
  • Added method addChildWithDimensions to Distribution.
  • Added getLoad, hasAsset, erroredLoads, loadingAndCompletedLoads, errored to GroupLoad.
  • Added static methods getGroupLoadById and getGroupLoadByAsset to GroupLoad.
  • Added the ability to add a GroupLoad into a GroupLoad.
  • Added the ability to get bytesLoaded of a GroupLoad, and bytesTotal after the GroupLoad has complete.
  • Added the option to define an unique identifier to a GroupLoad.
  • Fixed ProcessEvent‘s toString to return the correct properties.
  • Fixed a typo in the KeyComboEvent class.
  • Fixed an issue with CasaTextField in AIR.
  • Fixed an issue with AudioLoad when it attempts to retry a load. Thanks to Rob Gungor.
  • Fixed an issue with Sequence when a task is removed immediately after it completes.
  • Fixed bug in ProcessGroup which may case the group to run when not desired.
  • Fixed issue where GroupLoad would try to temporarily reload loads destroyed with destroyLoads. Thanks to Simon Lindsay.
  • Renamed AlignUtil‘s alignCenterMiddle to alignMiddleCenter for consistency.
  • Updated LoadEvent to no longer extend ProgressEvent.
  • Updated GroupLoad so it reports a more accurate load percentage.
  • Updated Process to only dispatches event STOP when destroyed if the Process was running when destroyed.
  • Updated FrameDelay to extend from Process.
  • Updated Interval so you cannot remove required internal event listeners.
  • Updated Distribution so it positions items with DisplayObjectUtil‘s getOffsetPosition to properly position scaled or offset DisplayObjects.
  • Updated AlignUtil so it positions items with DisplayObjectUtil‘s getOffsetPosition to properly position scaled or offset DisplayObjects.
  • Updated NavigateUtil so it fails gracefully if script access is not allowed.
  • Updated QueryStringUtil so it fails gracefully if script access is not allowed.
  • Updated StringUtil‘s getLettersFromString and toTitleCase to support non-english letters. Thanks to Tomaso Neri.
  • Updated documentation to address typos, add more examples and document all the CASA errors thrown.

1.3.0 Downloads & Documentation


Please note: We advise you to only use the latest release links. This way you can be assured that the version you are getting is the most up to date. We provide links to specific versions to be used in cases of forward compatibility issues.


Written by nadous on March 29th, 2010

Whoa! Didn’t update since 1.1 and 1.3 appears to be a hell of an update. Thx for your work!

Written by maru on March 30th, 2010

Yeah ! thank you for this !
Keep up the good work and long live to CasaLib :)

Written by NIKY on April 4th, 2010

THANKS!! It’s cool!

Written by amit on April 9th, 2010

Hi there,

I have read about your libs and have also checked out your site. It seems people are really benefiting from it but if you dont mind can you please clarify my doubt…

Everyone seem to be using your libs but I dont understand how can it benefit me… please forgive my ignorance… but all info i get about CASALib is only what you have written about it in your first para of intro “designed to streamline common chores”.

So on ground level.. if I want to develop my portfolio site to display a thumbnail gallery loading image info through XML file…. How can I use your libs to make my process easier?? or How else can these libs be helpful?

Thanks for your anticipated response.

Written by Aaron Clinger on April 10th, 2010

Hi Amit,

CASA Lib is designed to be used by experienced developers to make their lives easier. It assumes the developer has a good understanding about ActionScript, class based development and patterns. If you’re not that type of developer then it may not be the right library for you. I would suggest going over the documentation to see what each class does. If you find the class simplifies the work you typically do, then try it out. One of the nice things about CASA Lib is you can take what you find helpful and ignore what you don’t.

CASA Lib also doesn’t do everything for you. It doesn’t assume it knows the final product or force you to use a design pattern or framework to use it. It won’t build a thumbnail gallery for you, but it will help you with steps along the way; DataLoad for XML loading, ImageLoad for image loading, Tween/PropertyTween for fading and transitioning and maybe Sequence or Interval for timing between slides.

CASA Lib doesn’t provided a finished product, but rather gives you a versatile box of tools to build it.

I hope this helps a bit.

Written by amit on April 11th, 2010

Hi Aaron,

Thanks for the information. I am well versed with AS2 and have been using AS3 since past few months.

So as you said that it will help setting the building blocks… this is what I wanted to confirm. I am working on my portfolio site where I will be using Away3D. So I also wanted to try casalib in this project as I have noticed many user telling about the benefits.

Just a quick question? there are the main areas where I would like to use the libs: Preloader of the site, Preloader per thumbnail/image, Loading images/videos through XML, creating generic buttons for the site etc..

Can you please help me understand how will the libs be helpful in these areas? In the meanwhile I will study the documentation.

Thanks for taking time and explaining things.


Written by Dr. Benton on April 15th, 2010

Wouldn’t it be better, in the “_checkTotalPercentValidity()” method of GroupLoad, to check with the percentages instead of decimal percentages ?
If you have a lot of small percentages (i.e. 1% + 1% + 1% ...), because of small numbers lack of precision the sum calculated with decimal percentages can be different from 1 (1.000002 for my current project), and the Percents are recalculated. With ‘normal’ percentages sum, the result is 100 and the calculation is right.

Anyway, thanks for this great library !! :-)

Written by beez on May 19th, 2010

Wow. Thanks. I very much appreciate the library and I will forward anything i extend from it. So what’s up w/ the discussion board??? Is that getting underway?  Also I was wondering if you have any advise about getting data into 2 seperate UniqueList from one GroupLoad using the Casalib…

Again, this is greatly appreciated.


Written by Rex on August 10th, 2010

Really appreciate for your effort working on CASA, it is so useful =]

btw, I found a strange problem on GroupLoader.

I have created several external libraries(.swf) and try to load these files using GroupLoader and SwfLoad. The definition of classes have been loaded successfully .

However, when I tried to create an instance of Class A, it failed. It is because the instance that I want to create has another instance (Class B) in it. Flash fails to recognize the instance (Class B) inside Class A and throws an error.

var _btn:ClassB = this.getChildByName(“instanceB”) as ClassB;
trace(this.getChildByName(“instanceB”)); // return MovieClip
trace(_btn); // null
_btn.doSomthing(); // Throws error

The strange thing is ... if the file where ClassA and ClassB located is the last file in the queue of GroupLoader, it can be created successfully without any error.

I have tried to load the files separately using SwfLoad only, it works fine. Therefore, I doubt it is the problem caused by the GroupLoader.

Any ideas? =]

Written by Rex on August 10th, 2010

Sorry for misleading… Just double checked the case that using SwfLoad alone to load multiple external libraries and create instances. It fail too…

If I load a file and create instance one by one, it is okay. (i.e. Load a library, create an instance, load the next library, create next instance in that library…)

Written by chris on April 25th, 2011

Hi Aaron,

I’m currently working on a game right now and I’m using Casalib. Base on the latest release, can you show an example on how to properly use the object disposal methods when having nested casa display objects. I’m currently experiencing infinite loops when calling removeChildrenAndDestroy(true, true) from the top of the hierarchy.

Great lib BTW…it’s a gold mine!

- Chris

Written by Aaron on April 25th, 2011

Hi Chris,

Thanks for the complement!

removeChildrenAndDestroy is what you should be using, and should only be called from a parent (it obviously does not need to be called from children as the parent will be doing all the destroying of all nested children). I am not sure why you’re getting an infinite loop. Are you dealing with a very large number of children? Is there any code that is adding children constantly or reacting to removedFromStage? Also remember to override the destroy methods in each class to clean up any intervals, loads, etc. that you have added. This way when a destroy call is received, everything is cleared and ready for garbage collection. Let me know if you can provide us with anymore clarification and we can help you get to the bottom of this loop.


Written by Chris on April 25th, 2011

Hi Aaron,

I currently have the following classes:

SpriteButton extends CasaSprite
- label:CasaTextField
- button:CasaSimpleButton

MessageBox extends CasaSprite
- modal:CasaSprite
- mainContainer:CasaSprite
- background:DisplayObject added to mainContainer
- button:SpriteButton added to mainContainer
- message:CasaTextField added to mainContainer

SkinnedMessageBox extends MessageBox
- set background with Bitmap from library (override)
- set button upState, overState, downState with Bitmap from library (override)
- set button hitState with CasaShape (override)

CharacterExpositionPanel extends CasaSprite
- messageBox:SkinnedMessageBox
- character:CasaMovieClip

(Character’s name)ExpositionPanel extends CharacterExpositionPanel
- set character with CasaMovieClip animation from library (override)

All these classes don’t load anything, no intervals, etc. so no extra cleaning required. When the (Character’s name)ExpositionPanel’s removeChildrenAndDestroy(true, true) is called, sometimes it works and sometimes don’t (infinite loop). It’s not adding children constantly either. I’m really puzzled why the recursion fails sometimes.

Thanks for the quick response,

Written by Chris on April 25th, 2011

Hi Aaron,

I found the problem. It loops infinitely when it tries to remove the children of a MovieClip that has timeline animation. The animation consists of two sub MovieClips with animation also. All animations have CasaMovieClip as base class. Overriding the removeChildren and explicitly removing the character animation fixed it.

My question now is, does it work with nested timeline animations all having CasaMoveClip as base class?


Comments are no longer accepted for this blog post.