CASA Lib AS3 Release 1.2.0

Written by Aaron Clinger on July 22nd, 2009

It has been a long five months, but we are excited to be finally releasing the next version of CASA Lib! We’ve realized that five months is way too long to go between releases and will start releasing smaller updates more frequently.

While the site updates have slowed, our work on the code base has continued aggressively. This version contains a complete reorganization of the load classes and a ton of great additions. Special thanks to Jon Adams for his major contributions. Below is the long list of improvements.

Change Log

  • Added static methods from and to to ProperyTween to enable faster development by removing the need to create an instance and then call start.
  • Fixed a bug in Sequence class that prevented resuming.
  • EnterFrame now throws an Error if destroy is called (it’s a singleton).
  • Added a MAX_THREADS constant to ProcessGroup. You can use this constant to set ProcessGroup’s threads to the maximum allowed to virtually disable threading.
  • Added hasProcess to ProcessGroup.
  • Updated ProcessGroup‘s autoStart property to automatically start the group without having a new process added.
  • Added the ability to get queued, running, incomplete and completed processes and loads in ProcessGroup and GroupLoad.
  • Fixed issue with GroupLoad where the group would report complete before the items had dispatched their complete event.
  • Added hasLoad to GroupLoad.
  • Updated VideoLoad so it will report buffer and progress faster.
  • Added a getter metaData directly on VideoLoad so you no longer need to add an event to capture it.
  • LoadItem and CasaLoader now return positive infinity for bytesTotal if no content length header was found. Once the file is loaded it will return the accurate value.
  • Added getters latency, url, time and httpStatus to LoadItem.
  • Updated LoadEvent to contain all properties of LoadItem.
  • DataLoad throws errors if you try to access data before it’s loaded or if it cannot convert it to the proper type.
  • DataLoad now automatically turns strings to URLVariables and vice-versa in case of misdefined data format.
  • Added the ability to define data format for DataLoad.
  • Added the ability to get data as String and ByteArray from DataLoad.
  • Split GraphicLoad into two classes; SwfLoad and ImageLoad. GraphicLoad no longer exists.
  • Removed LibraryLoad, the new SwfLoad class now contains all the functionality of LibraryLoad.
  • Removed BaseLoadItem because it is no longer needed.
  • Added getGroupIdBySwfLoad and getGroupIdByDefinition to LibraryManager.
  • Fixed bug in LibraryManager that prevented class creation from non-default groups.
  • Added CasaSimpleButton.
  • CasaBitmap and CasaTextField now also have a stage getter that will return StageReference’s default stage if the display objects have not been added to the display list.
  • Made CasaMovieClip a dynamic class so that it behaves more in line with the native MovieClip class.
  • Made Distribution extend from CasaSprite.
  • Added align outside parameter to AlignUtil.
  • Added getItemByType, getItemsByType, getItemByKey and getItemsByKey to ArrayUtil.
  • Fixed an issue in DateUtil’s iso8601ToDate when converting date to local time zones near midnight.
  • Added DisplayObjectUtil with a removeChildren method.
  • Optimized RatioUtil and added snapToPixel option.
  • Added htmlEncode, htmlDecode, isNumber and getWordCount to StringUtil.
  • Made minor improvements to StringUtil‘s toTitleCase.
  • Added classSmallCaps and formatSmallCaps to TextFieldUtil.
  • Fixed mistake in GeomUtil’s angle method that only returned 180 degrees instead of 360.
  • Added a getWeightedAverage function to NumberUtil.

1.2.0 Downloads & Documentation

ZIP: http://as3.casalib.org/releases/1.2.0/1.2.0.zip
SVN: http://svn.as3.casalib.org/releases/1.2.0/
Documentation: http://as3.casalib.org/releases/1.2.0/docs/

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.

Comments

Written by Khanh on July 22nd, 2009

Hi Aaron!
I’m a fan of casa framework :)
I have big problem with SingletonUI. I must say that is a good idea, but I can’t use it as well as your tutorial.

Sample I have a class name as MyClass, in contructor of MyClass, i trace (this,” is create”). And in main.as, I have some code


var mclass:MyClass=new MyClass();
var nClass:MyClass=SingletonUI.singleton(MyClass)
” And :((
It trace twice string in contructor of MyClass

Any ideas for this sample, maybe i wrong some code :(

Thanks

Written by Khanh on July 22nd, 2009

And, my personal comment,  that’s in GroupLoad, it’ should be dispathEvent a event (such as ITEM_LOADED) when a item was loaded, and return data of this Event maybe is content,url,name,value…of item you load. It’ useful when you need load many external assets, so you can’t wait until progress complete, you like show each item when it was loaded…
Anyway , that’s my personal idea

Written by Aaron on July 23rd, 2009

Hi Khanh,

Glad you like the library. The SingletonUtil is designed to help create singletons out of a class without adapting or extending the class itself. If you have the ability to extend the class or create your own, I’d always suggest doing it that way. The SingletonUtil will not change how the class natively acts, so in your case if you create a bunch of new MyClass they will be unique instances. Though if you always reference SingletonUtil.singleton(MyClass) you will always get the same instance. Here is a further example:

package {
import flash.display.MovieClip;
import org.casalib.time.Stopwatch;
import org.casalib.util.SingletonUtil;
import flash.events.Event;

public class MyExample extends MovieClip {
  private var _stopWatch:Stopwatch;
 
 
  public function MyExample() {
  super();
 
  this._stopWatch = SingletonUtil.singleton(Stopwatch);
  this._stopWatch.start();
 
  this.addEventListener(Event.ENTER_FRAME, this._onEnterFrame);
  }
 
  private function _onEnterFrame(e:Event):void {
  trace(this._stopWatch === SingletonUtil.singleton(Stopwatch));
  trace(SingletonUtil.singleton(Stopwatch).time);
  }
}
}

Written by Aaron Clinger on July 23rd, 2009

Hi Khanh,

You can receive an event when an item in GroupLoad is loaded. You do this by adding an event to the individual load class before adding it to the GroupLoad. Hope that helps.

Written by mario gonzalez on July 23rd, 2009

Hi there, I’ve used the casa library on a few projects, and one thing I can’t understand is why it tries to re-invent the wheel with the barebones tweening library?

It’s arguable that tweening is the most common denominator, in all flash projects i’m willing to be that 90 percent of casa users don’t use the anemic casa tween library and instead use (Tweenlite / Tweener / GTween / BetweenAS3) - seems superfluous and counter productive.

That’s just my opinion, it’s not meant to be flamebait it’s just that I feel like casalib isn’t trying to be a - this is the only thing you need ever - library, so i never understood that addition to it.

Written by Aaron Clinger on July 23rd, 2009

Hi Mario,

No offense taken at all, I totally understand what you’re saying.

CASA Lib’s tween classes is not meant to compete with all the great tween libraries out there. As you mention it is really bare bones. I use other tween classes in my own projects all the time. It’s just meant to be a very simple tween class that users can extend. Even though I use other tween libraries, I still find myself using CASA’s tween regularly when I need to tween something in a highly custom way and want something simple to extend from.

One of the things I love about CASA is that it’s a library, not a framework. You can use it along side other classes or frameworks, and you can use what you like and ignore what you don’t. As you mention, CASA doesn’t try to be the end all to everyone. It strives to be a strong, flexible and generic foundation to build on.

Thanks for speaking up. Let me know if you’d like me to elaborate on anything further.

Written by FG on July 25th, 2009

Thanks guys, your library is great! It really saves a lot of time! Thank you very much again!

Written by Jeff L on July 29th, 2009

Hello,

I am having a weird problem with the LoadEvent event. When i create a progress event ex: function onProgress(e:LoadEvent){} i have a trace to display the percentage loaded ex: trace(e.progress.percentage); and it traces (0,0,0,0,100%) as it runs… Am I using this event wrong?

Written by Aaron on July 29th, 2009

Jeff you are using the event correctly. Which load class are you using?

Are you testing this locally? It might be that the asset instantly. Or if you are trying to load an asset that is being generated from a server side script make sure it is returning a Content-length in the header (this lets flash know how big the file is and determines an accurate load percentage).

Let me know if this doesn’t help.

Written by Jeff on August 2nd, 2009

I am using the DataLoad class, I am working with an php/mysql api that is on our server that when called it returns xml data… Oh, I am testing locally, but the api calls generate from a live server…

Written by Zeke Sikelianos on August 4th, 2009

I’m not sure how long it’s been wrong in the docs, but the example used for ArrayUtil.removeItem is written as ArrayUtil.removeArrayItem .. confused me for a bit when I copy/pasted the example and couldn’t compile.

Written by Aaron on August 5th, 2009

Thanks Zeke for bringing that to our attention. I’ve updated the docs.

Written by Aaron on August 5th, 2009

Jeff make sure this API is returning a Content-length in the header. I’ve had this issue a lot and needed to update the code to return it’s length. Flash uses (not just CASA Lib) the Content-length to determine the size of a file. If it is absent, Flash will not know how large a file is (and how much has loaded) until the file has finished loading.

Written by Jeff L on August 5th, 2009

Ok, I’ll check…. Thanks!!

Written by Dr. Benton on September 1st, 2009

I think I found a bug in SwfLoad : even if you specify a LoaderContext, it is not used in the class. The use of “this._context” is missing in the “_load” method.
This bug prevents the use of “new LoaderContext(false, ApplicationDomain.currentDomain)” when you load SWFs…

Written by ketsu on September 2nd, 2009

Hello! I just ran into the same problem Dr. Benton mentioned above. And I can confirm it, that SwfLoad class is missing context usage in _load method. It should look like this:
override protected function _load():void {
        if (this._classRequest == null){
          this._loadItem.load(this._request, this._context);
        } else
          this._loadItem.loadBytes(new this._classRequest() as ByteArray, this._context);
      }

Written by Aaron on September 6th, 2009

Thanks Dr. Benton and Ketsu for reporting that error. It has been fixed in the 1.2.1 release.

Comments are no longer accepted for this blog post.