Subscribe

  • Subscribe  

A Nice ActionScript 3 ResourceMap API

Posted by Charles | February 28, 2008 .

Eric Feminella developed this open source AS3 HashMap API awhile ago. I’d like to revisit it because the Flex 3 released. In Flex 3, one small new feature is that you can access the ResourceBundle data. Eric has a ResourceMap API developed, which allows developers to work with a ResourceBundle via an IMap implementation.

So how well Eric’s ResourceMap API compare to the new Flex 3 ResourceManager?

According to Eric:

ResourceMap implements the IMap interface allowing the underlying content of a ResourceBundle to have CRUD specific operations performed on it. To utilize the ResourceMap one only need to instantiate an instance of ResourceMap and pass in a ResourceBundle.

The code looks like this:

import com.ericfeminella.collections.ResourceMap;
import com.ericfeminella.collections.IMap;
import mx.resources.ResourceBundle;
 
[ResourceBundle("resources")]
private static const rb:ResourceBundle;
 
var map:IMap = new ResourceMap( rb );

Eric said “The benefit to this approach is it allows developers to dynamically add, remove, update and delete resources at runtime, whereas the new Flex 3 ResourceManager (much like the Open Source ResourceManager API I created last year – had to add that in) does not provide an API for setting resources. In addition, all of the getters defined by the IResourceBundle interface and implemented by ResourceBundle have been deprecated in favor of the new ResourceManager. However, IResourceBundle now provides an additional operation called getContent(); which exposes a reference to the underlying content Object which is created when a .properties file is compiled. Therefore it is possible to take advantage of this by accessing the content object.”

I like the ResourceMap approach, it’s clean and simple. Somehow it reminded me those days of Open Source Java libs vs Sun’s implementation. Adobe can learn a lot from the Java evolution, so does Flex/ActionScript developers.

Leave a Comment

If you would like to make a comment, please fill out the form below.


Name

Email

Website

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comments

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Related Posts

1 Comment so far
  1. puppyfist  February 28, 2008 1:56 pm

    Adobe doesn’t need to look at Java for evolution. Java has fallen behind for web development because it’s too complex.

    Adobe is on the right path. I’ve met too many AS3 programmers that try to jam their code with every pattern around making it slow and not enhanced for performance.

    There is a middle ground.

<

Direct TV Offers - usdirect has the best directtv deals