PDA

View Full Version : this.loadMovie Trouble



aspiring wings
November 10th, 2005, 05:29 PM
I am new at this forum. I posted at devshed.com. No help there. I am still trying to learn AS2.0 OOP as well. Any help would be appreciated.

I have an object that extends a movie clip. I would like to load an external clip within this class defininition like so:

class Backdrop extends MovieClip;
public function init():Void {
this.loadMovie("backdrop.swf");
}
}

When i do so, there i get this error: "Target not found: Target="undefined" Base="_level0""

Now, i have also tried this:

class Backdrop extends MovieClip {
public function init():Void;
loadMovie("backdrop.swf", this);
}
}
That should do basically the same thing, but AS doesn't allow it because the second parameter expects a MovieClip, not a Backdrop object.

Now if i manually enter the target with
_root.backdrop.loadMovie("backdrop.swf"); that works, but it seems to me that defeats the purpose of putting it in the class definition in the first place. It is not abstract that way.

I hope i am making sense. Basically, i want to know if either
(a) There is a way to trace the target of the this property or
(b) If there is a way to force the loadMovie function to take subclass from the MovieClip object

iloveitaly
November 10th, 2005, 06:15 PM
(a) There is a way to trace the target of the this property or
why not just add trace(this); in your init function?


(b) If there is a way to force the loadMovie function to take subclass from the MovieClip object
Your problem is that loadMovie is defined two ways, as a global function and as a MovieClip method. calling: loadMovie("backdrop.swf"); should work since your actually calling the MovieClip loadMovie method.
HTH!

aspiring wings
November 12th, 2005, 01:34 PM
Yes, that makes perfect sense. However, trace(this) only yeilds [object Object]. Not too helpful. trace(this._target) yeilds undefined. loadMovie("backdrop.swf") does not work because AS is expecting a second parameter, which is why i wrote this.loadMovie("backdrop.swf"). So i still cannot get it to work.