Instantiate class from loaded xml image (workaround)

Background: I needed to duplicate an image loaded into the Flash movie with XML. What I wanted to do was to create a new class of that MovieClip so that creating multiple instances of that MovieClip/Sprite wouldn’t be a problem, but I couldn’t get it working without external ActionScript class files (felt like too much hassle for a small project like this). I’ll continue on this code though when there is more time and hopefully follow up on it. Though maybe a solution like that, creating a new class instance of a loaded image, would be resource heavy for the Flash Player. I don’t know.

Anyway, here’s what I did:

var bigTickMarkBitmap:Bitmap;
 
bigTickMarkBitmap = e.target.loader.content as Bitmap;

I’m using the loader class to read the data and create a new Bitmap. Then, when I want to create multiple instances of this, I do the following:

for(var i:int=0; i<10; i++) {
var tmp:Bitmap = new Bitmap();
tmp.bitmapData = bigTickMarkBitmap.bitmapData; // this duplicates the bitmap data from the loaded bitmap
 
var bigTick:MovieClip = new MovieClip();
bigTick.addChild(tmp);
tickMarkContainer.addChild(bigTick);
}

I also tried code like this, but with no luck:

var SomeClass:Class = Class(getDefinitionByName("bigTickMarkBitmap"));
var obj:Object = new SomeClass();
 
var sprite:DisplayObject = target.addChild(DisplayObject(obj));
 
return Sprite(sprite);

Splitting string with delimiters

Splitting a string with delimiters, i.e. commas, into an array was easy.

I had an XML-file with multiple possible values for one start value. These would be used to populate a drop down:

<startValue>1</startValue>
<endValue>1,2,3,4,5</endValue>

Alas, I needed to split the endValue property into an array:

var tmp:String = xmlList.endValue.text();
var array:Array = tmp.split(",");
trace(array);