Hello,
I'm setting up a class of public static vars that are to be BitmapData.
The problem I'm having is I can't seem to reference the vars dynamically in an array, making it impossible to give them values without some serious procdedural style coding.
This is what it looks like
package com.myPackage{
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class Images extends Sprite{
private var url1:String = "http://www.mydomain.com/myImage.jpg";
private var url2:String = "http://www.mydomain.com/myImage2.jpg";
public static var IMAGE_ONE_BDATA:BitmapData;
public static var IMAGE_TWO_BDATA:BitmapData;
private var urlArray = new Array(url1,url2);
private var bDataArray = new Array(IMAGE_ONE_BDATA, IMAGE_TWO_BDATA);
private var count:int = 0;
public function Images(){
initLoader();
}
private function initLoader():void
{
if(count < urlArray.length){
var url:String = urlArray[count];
var loader:Loader = new Loader();
loader.load(new URLRequest(url));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function (e:Event):void{
bDataArray[count] = e.target.content.bitmapData;
trace(IMAGE_ONE_BDATA) // <-- this should trace ([object-bitmapdata]) but instead returns null.. this is where I have to make a direct reference like..
IMAGE_ONE_BDATA = e.target.content.bitmapData;
trace(IMAGE_ONE_BDATA) // <-- will now return my bitmapdata object
count++;
initLoader();
}else{
dispatchEvent(new ImagesLoadedEvent);
}
}
}
Should I assume it's because my array is a private var and placing references to public static vars is illegal? Is somebody gonna call the flash police on me?
Any input highly appreciated.
-Jascha