Another solution:

// ActionScript 2.0 Class Definition: com/ArrayExtension.as
dynamic class com.ArrayExtension extends Array {
        function ArrayExtension() {
                if (arguments.length == 1 && !isNaN(arguments[0])) {
                        this.length = arguments[0];
                } else {
                        this.push.apply(this, arguments);
                }
        }
}

// fla for Testing
// Frame Action
import com.ArrayExtension;
var arEx0:ArrayExtension = new ArrayExtension("one", "two", "three");
trace([arEx0.length, arEx0]);  // Output: 3,one,two,three
var arEx1:ArrayExtension = new ArrayExtension(3);
trace([arEx1.length, arEx1]);  // Output: 3,undefined,undefined,undefined

// [Debug] > [List Variables]:
Variable _level0.arEx0 = [Object #3] [
    0:"one",
    1:"two",
    2:"three"
  ]
Variable _level0.arEx1 = [Object #4] []
_____
Mike Britton wrote:
class com.ArrayExtension extends Array
{

   public function ArrayExtension()
   {
       super()
        var argString = arguments[0].split(",");

       for(var i=0; i< argString.length; i++)
           push(argString[i]);

   }

}

Usage:

var arEx = new ArrayExtension("one,two,three");
trace(arEx.length);

Good luck,

Fumio Nonaka
mailto:[EMAIL PROTECTED]
http://www.FumioNonaka.com/
My books<http://www.FumioNonaka.com/Books/index.html>
Flash community<http://F-site.org/>

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to