So I’m trying to make an imageviewer in flash, using the concept of OOP. Inside one of my classes I’m using an MovieClipLoader to load an image. When the loading starts, I want to use my classvariable “preload” to show a preloader (which is another class of mine). However, when I try to use the this-keyword to call my preload-variable inside the onLoadStart, it will refer to the listener, not to the class (in this case TestClass).
It’s possible to use a _global to define my preload variable, but I try to avoid using _globals. Because I also use the onLoadProgress and the onLoadInit listeners it would mean that everything in my class would have to be a _global to be able to use them. Is there another way of referring to my preload variable?
Here’s a sample code of what I mean:
class TestClass {
var mc_holder:MovieClip;
var testvariable:Number;
var preload:Preloader;
var loadImageListener:Object;
var movieClipLoader:MovieClipLoader;
function TestClass(mc_holder:MovieClip){
this.mc_holder = mc_holder
this.preload = new Preloader();
this.loadImageListener = new Object();
this.movieClipLoader = new MovieClipLoader();
this.movieClipLoader.addListener(loadImageListener);
loadFunction();
}
function loadFunction():Void{
movieClipLoader.loadClip("image.jpg", this.mc_holder);
loadImageListener.onLoadStart = function():Void{
this.preload.startloading(); //--> UNDEFINED
};
}
}
I really hope someone can help me out with this one.
Thanks in advance!