cdk57
11-11-2006, 11:05 AM
For example:
class Photo() {
public function Photo() {
var loader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
_root.objRef = this;
listener.onLoadInit = function() {
_root.objRef.doSomething();
}
loader.addListener(listener);
loader.loadClip(url, containerMC);
}
public function doSomething():Void {
trace("loaded");
}
}
As you can see, in order to call the method doSomething() once the clip has been loaded, I'm having to store a reference to the object in _root. What's the proper way of doing this?
For example, is there a way to pass a reference to the object into the onLoadInit() anonymous function through a parameter?
Thanks
class Photo() {
public function Photo() {
var loader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
_root.objRef = this;
listener.onLoadInit = function() {
_root.objRef.doSomething();
}
loader.addListener(listener);
loader.loadClip(url, containerMC);
}
public function doSomething():Void {
trace("loaded");
}
}
As you can see, in order to call the method doSomething() once the clip has been loaded, I'm having to store a reference to the object in _root. What's the proper way of doing this?
For example, is there a way to pass a reference to the object into the onLoadInit() anonymous function through a parameter?
Thanks