PDA

View Full Version : AttachMovie problems..


m.i.c.
01-31-2006, 07:33 PM
Been breaking my head on this one :

var currentFolder_mc:MovieClip=folderMovie_mc.attachMo vie("folderMovie_mc","folder_"+i, 50+i);

how come this keeps on returning undefined? If creation succeeded this function should return the link the the new movie no? So appearently the creation keeps failing.... I have a movie called "folderMovie" in my library with the linkage set to "export:folderMovie" , export on first frame.

The attachMovie function above is called on the second frame...
Anyone?

Thanks!

flashead
01-31-2006, 07:35 PM
you said your linkage is set to: folderMovie.
but your attachMovie seems to be looking for: folderMovie_mc

k.

m.i.c.
01-31-2006, 07:40 PM
Sorry, my mistake!
The linkage is also FolderMovie_mc...

flashead
01-31-2006, 07:42 PM
are you tracing it directly after you've attached it (on the next line below the attachMovie)? or afterwards?
and you're trying to attach it inside another movie clip called 'folderMovie_mc'. did you trace that to see if it's available at that point?
k.

m.i.c.
01-31-2006, 07:50 PM
I'm checking if the attachMovie succeeded directly after the command :

function displayFolders(){
for(var i=0;i<folders.length;i++){
trace(folders[i]);
var currentFolder_mc:MovieClip=folderMovie_mc.attachMo vie("folderMovie_mc","folder_"+i, 50+i);
if (currentFolder!=undefined) {
currentFolder._y=i*20;
trace (currentFolder._y);
currentFolderText_txt=folders[i];
trace(currentFolderText_txt + " y pos = " + currentFolder._y);
currentFolder.createTextField("currentFolderText", 1+i,0,0,200,20);
}
else {trace("creation failed");}
}
}


but it always traces "creation failed", and no movies are created anywhere

flashead
01-31-2006, 07:56 PM
ok and part 2 of my last question again:
what happens when you trace the movieclip you're trying to attach these movies inside of?

function displayFolders()
{
for( var i=0; i<folders.length; i++ )
{
trace( folders[i] );

var currentFolder_mc:MovieClip = folderMovie_mc.attachMovie( "folderMovie_mc", "folder_" + i, 50 + i );
trace( folderMovie_mc ); // what does this return?

if ( currentFolder != undefined )
{
currentFolder._y = i * 20;
trace ( currentFolder._y );

currentFolderText_txt = folders[i];
trace( currentFolderText_txt + " y pos = " + currentFolder._y );

currentFolder.createTextField( "currentFolderText", 1 + i, 0, 0,200, 20);

} else trace("creation failed");
}
}

m.i.c.
01-31-2006, 08:03 PM
this also returns undefined... (the word of the day ;) )
By the way, how do you get the code in this formatted form?

sophistikat
01-31-2006, 08:14 PM
use [ as ] and [ /as ] without the extra spaces, just a small note: on post #3 you said that the linkage name is FolderMovie_mc but in your script you typed folderMovie_mc

flashead
01-31-2006, 08:14 PM
this also returns undefined... (the word of the day ;) )

well then that's your answer right there. it can't find the movie clip to attach them to. so now you have to figure out why! :)

... By the way, how do you get the code in this formatted form?
wrap your actionscript code in [as] tags to format it properly ;)
k.

m.i.c.
01-31-2006, 08:22 PM
ok thanks i'll remember the [as] tags!
But the linkage is ok (it says folderMovie_mc) i should triple check the things i write here like i do in my programming :)

But yes appearently flash can't find the movieclip to attach the new movies to. But i don't really understand this since the movie is in my library. I also tried to put an instance on stage with the same instance name (folderMovie_mc), but still no succes... What could be the possible reasons that Flash doesn't find a movie, although it's in your library AND on stage?

flashead
01-31-2006, 08:39 PM
wow, sounds like you're really mixed up.

to attach a movie to the Stage from your Library you would use:
_root.attachMovie( "linkageID", depth );

where _root is being used to reference where you want to attach the mc. and linkageID is being used to reference what you want to attach.

so when you have:
folderMovie_mc.attachMovie( "folderMovie_mc", "folder_" + i, 50 + i );
that means that at the moment that code is called, there is a movie clip called folderMovie_mc which is currently on the stage and in frame.

the path before the attachMovie is just a target path to a movie clip, it has nothing to do with linkage or library names.

k.

m.i.c.
01-31-2006, 09:29 PM
thanks for that info! You see, i never created movieclips in this way so perhaps i wanted to go too fast... (i never quite understood the purpose of the linkage identifier, but now i know why ;))

So i've tried the new code and now it WORKS!!

I'm a happy man ;)

Thanks again and sorry for this silly 'beginners question'!