Skip to main content
Inspiring
April 5, 2007
Question

attachMovie fails

  • April 5, 2007
  • 4 replies
  • 302 views
hi,
i'm trying to attach a symbol to a loaded clip so far unsuccessfully. i've
found older threads in this forum, tried to implement what i've found there,
but that didn't help either.
this is my basic code:

function loadLogo(lFile){
var mclLogo:MovieClipLoader = new MovieClipLoader();
var logoListener:Object = new Object();
logoListener.onLoadInit = function(target:MovieClip){
inv = setInterval(_level0, "loadComplete", 1000,target); // using
this interval to make sure the clip is completely loaded
}
mclLogo.addListener(logoListener);
mclLogo.loadClip(lFile,this.logo_mc);
}

loadComplete = function(_mc:MovieClip) {
var tt:MovieClip = _mc.attachMovie("toolTip","tt_mc",1);
trace(tt); // always returns 'undefined'
tt._visible = false;
_mc.onRelease = function() {
// some code
}
_mc.onRollOver = function(){
// some more code
}
_mc.onRollOut = function() {
// and here too..
}
clearInterval(inv);
}

loadLogo("logo.jpg")
// end of code

i have on the stage an empty movieclip 'logo_mc', and in the library a
symbol with the linkage identifier 'toolTip'.
the logo loads fine, but after a second in get in the message window
'undefined'
any tips?
thanks in advance,
eRez
www.cinabu.com



This topic has been closed for replies.

4 replies

kglad
Community Expert
Community Expert
April 5, 2007
yes, you're correct. but he knows his load is working or the onLoadInit() wouldn't execute and the trace() function wouldn't be called.

to ensure his linkage id is defined correctly. he can comment out the loadLogo() call and just test:

inv = setInterval(_level0, "loadComplete", 1000, logo_mc);

which should trace() correctly.

in that situation, the problem would be isolated to a flash issue.
Inspiring
April 5, 2007
Oh. I guess I had run into that as trying to attachMovie to a failed external load. It had never occured to me that it was just a general problem for the whole shebang!

I still stand by some of my other suggestions however…
kglad
Community Expert
Community Expert
April 5, 2007
actually, i think there's a problem (bug) when you try to attach to a movieclip that's been the target of loadMovie().
Inspiring
April 5, 2007
Add the following to your loadComplete:

trace("current scope is: "+this);
trace("current target clip is: "+_mc);

What do you get?

Also, the onLoadInit shouldn't have a problem with the external file being totally loaded so I would ditch the setInterval, it just makes everything more comples than it needs to be.

Also, I would change the name from loadComplete to something more descriptive, like attachToolTip, just in the sake of clarity. At first I though you had incorrectly used the MCL onLoadComplete event.

Also, if you want everything from the scope of the attached movie and you intend to use the setInterval why not do this:

target.inv = setInterval(target, "attachToolTip", 1000);

And then inside the function you can use this.attachMovie() etc.

Using _level0 is bound to cause you problem at some point.

Finally, make sure that there really is a clip with a linkage name of toolTip in the library. Actually that is the first thing you should probably do. You would be surprised how many times that somehow goes wrong! :)