My loadJPG function doesn't work with "this"

This works:

_global.loadJPG = function (name, mc, x, y) {
createEmptyMovieClip(mc, m++);
_root.[mc].moveTo( x, y);
loadMovie (name, mc);
}

This doesn’t work:

_global.loadJPG = function (name, mc, x, y) {
this.createEmptyMovieClip(mc, m++);
this[mc].moveTo( x, y);
loadMovie (name, mc);
}

Why doesn’t “this” work? I need it because this function is not always called from the _root.

Ron

Try this:

_global.loadJPG  = function (name, mc, x, y) {
  this.createEmptyMovieClip(mc, m++);
  this[mc].moveTo( x, y);
  this[mc].loadMovie (name);
}

Any help?

pom :cowboy:

I tried this also, and no luck.

It seems that no empty clip is being created in the first place.

Without the “this” it works.

Help

ROn

Well, I’m not sure, but I think that _global is an object. So maybe you’re creating a clip in that object, which may not be possible. I’m just guessing here.

Did you try the function without _global in front?

pom :slight_smile:

ily’s on the money.

_global is not a movie clip and thus doesn’t have the methods that are available to movieclips. try writing it as a movieclip method.


MovieClip.prototype.loadJPG  = function (name, mc, x, y) {
  var clip = this.createEmptyMovieClip(mc, m++);
  clip.moveTo( x, y);
  clip.loadMovie (name);
}

Great guys this makes sense, and works. Except for the moveTo. It doesn’t seem to take the positioning.

clip.moveTo( x, y);

Doesn’t work

clip._x = x; clip._y = y;

This does?

I guess I can live with. But why?

Ron

moveTo is part of the drawing api, not a method to change the x,y of a movieclip.

but given the wording, you could be excused for the mistake. ; )