PDA

View Full Version : Address movieclip inside a class...


RedMage
11-16-2002, 05:52 AM
I'm having trouble addressing a movieclip that I loaded through the constructing an instance from a class in a method of the same class.
This:

function CONT(loc,alias) {
this.fileurl = loc + "_mc";
this.name = alias;
}
CONT.prototype.test = function() {
_root.attachmovie(this.fileurl, this.name,1,{_y:25,_y:25});
_root.this["name"].bar._width = 50
}


I'm trying to attach a movie clip exported from my library and that works. But when I try to address a movie clip inside the movieclip without knowing a head of time what that name is until I define the object. If I know the name and type it like this:

function CONT(loc,alias) {
this.fileurl = loc + "_mc";
this.name = alias;
}
CONT.prototype.test = function() {
_root.attachmovie(this.fileurl, this.name,1,{_y:25,_y:25});
_root.movieClip_name.bar._width = 50
}

Then I works. Is there a way to do this? Sorry if this is difficult to understand, I can't explain it very well...

Timothee
11-16-2002, 09:34 AM
Your syntax is wrong, try this:


function CONT(loc,alias) {
this.fileurl = loc + "_mc";
this.name = alias;
}
CONT.prototype.test = function() {
_root.attachmovie(this.fileurl, this.name,1,{_x:25,_y:25});
_root[this.name].bar._width = 50;
}


Be careful hardcoding the depth within the prototype method because the clips will overwrite each other if you want to attach movies from several of your CONT class.

Tim.

RedMage
11-16-2002, 05:42 PM
Thanks, it works.
I wasn't planning on hardcoding the depths, that was just a test because I coudln't figure out was the hell, so I simplified it to see if I could get it to work. Thanks for your help though, much obliged.