Dynamic event handlers onLoaded jpgs?

ok, so i’ve been trying to use dynamic event handlers for everything lately ever since i discovered them. but i’ve run into a problem. when i’m loading jpgs into a movie clip it erases the handlers that i put on them example:

movieClip.prototype.traceName=function(){
trace(“this._name”);
}
this.createEmptyMovieClip(“pan_b”,1);
this.pan_b.onEnterframe=traceName;
//this.pan_b.loadMovie(“pann.jpg”);

then when i load in the jpg into that clip it stops tracing. i can’t even try and put the handler back on to the clip. Now i would be fine with this and try to find a different way if it weren’t for the fact that if you don’t use a dynamic handler and put it onto a created clip it will work. which makes me think there is a way its just probably some tricky syntax or something. i’ve been working on it for a while so i’m sure enough that its not a typo.
what i’m trying to do is check when it gets done loading into the clip so i can have it appear or whatever. onData…
any help would be much appreciated,
thanks

If those are an exact copy of the code you put into script… I’ll fix soem mistakes and give you something cool to check out :slight_smile:



MovieClip.prototype.traceName = function()
{
   trace("this._name");
}
_root.onLoad = function()
{
   this.createEmptyMovieClip("pan_b", 1);
   loadMovie("pann.jpg", _root.pan_b);
}
pan_b.onEnterFrame = function()
{
   this.traceName();
}

Tell me if this is about the effect you wanted… You can also make it where you can tets if the jpg has fully loaded or not yet… And then when it is fully loaded do all the tracenames… But that should return what you want… Should.

:slight_smile: I fixed some uppercase problems too you might have had :wink:

this line looks weird … :crazy:

MovieClip.prototype.traceName = function() {
trace(**"this._name"**);
}
MovieClip.prototype.traceName = function() {
trace(**this._name**);
}

it looks better now :slight_smile:

lmao… Good call again…

I missed that one… :slight_smile:

One Hint for ya… Check your spelling and your uppercase and lowercase placement with the ones flash has… it’ll save you time in the long run…

Thanks for pointing out my “quote” error there kax :wink:

no problem playa :slight_smile:

that’s why we are here anyway :wink:

That won’t work either (well it shouldn’t), Playamarz, because loading inside a clip will erase anything in that clip, including event handlers, and you can’t assign even handlers before the jpg is fully loaded.

The trick is to preload the jpg, wait for it to be fully loaded, and then assign the handler.

pom :tie:

No sheit?

Humph… Well that’s stupid… lmao

Could you possibly have a movie clip inside of pan_b that laods up the variable? Or would that take the movieclip it’s in and screw it up…?

Yep, that’s actually a very good way to solve the “problem” (not really a problem, as it’s actually quite logical).

pom :phil:


MovieClip.prototype.traceName = function()
{
   trace(this._name);
}
_root.onLoad = function()
{
   loadMovie("pann.jpg", _root.pan_b.loadArea);
}
pan_b.onEnterFrame = function()
{
   this.traceName();
}

That look a little better…? I’d suggest doing it this way… And having the actual blank mvoieclips made through the use of the FLash MX drawing interface… It’ll be cleaner that way… Juts make a movieclip names pan_b then make a movieclip inside of tht movieclip names loadArea.

ok sure that all makes sense, but i don’t really want it to trace the name on the enter frame i just want it to trace once that loadArea gets loaded. i don’t want a whole bunch of enterframes running at the same time.