Groups | Blog | Home
all groups > flash actionscript > march 2007 >

flash actionscript : linked library items via MovieClipLoader?


Raymond Basque
3/20/2007 3:22:02 PM
Works for me.


var mc = this.createEmptyMovieClip("test_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
// child movie contains MCs with linkage IDs
// attach an instance of "testclip"
var _d = target_mc.getNextHighestDepth();
target_mc.attachMovie("testclip", clip+_d, _d,{_x:30,_y:30});
};
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(mclListener);
mcl.loadClip("child.swf", mc);

Raymond Basque
3/20/2007 3:24:02 PM
Oops! Missed some quotes:

var mc = this.createEmptyMovieClip("test_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
// child movie contains MCs with linkage IDs
// attach an instance of "testclip"
var _d = target_mc.getNextHighestDepth();
target_mc.attachMovie("testclip", "clip"+_d, _d,{_x:30,_y:30});
};
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(mclListener);
mcl.loadClip("child.swf", mc);

liquidleaf
3/20/2007 6:56:00 PM
So, some of you may have run into this before. I know there is a known issue
with importing an SWF to a MovieClip using LoadMovie - in that, any library
items in the SWF that have linkage IDs can only be attachMovie'd within the
MovieClip itself, and not in the main timeline (or any other timeline).

However, I'm ok with this limitation.

I have a project where I'm creating an empty movieclip on the main timeline,
called "clip_1".

I then use a MovieClipLoader object to load an external SWF ("buttons_1.swf")
into clip_1.

This works.

However, buttons_1.swf has several button clips with linkage IDs set. What I
want to do is, after buttons_1.swf has successfully loaded into clip_1, then do
something like
clip_1.attachMovie("btn_play", "play", 1);
where "btn_play" is the linkage ID of a button in buttons_1.swf.

This does not work... and it probably should given that apparently some people
get a similar thing to work with loadMovie(). I want to use MovieClipLoader,
however, because of the built-in error catching and completion features of that
class.

I cannot use the "runtime sharing" workaround for this, because I will have a
potentially unlimited, unknown "button" SWFs that will be used. The main movie
will load the appropriate button library at runtime, but I can't know in
advance what all the libraries will be, and after the main movie is published,
ideally I cannot go in and edit it again (want to have it dynamic as possible
from the beginning).

Any help would be appreciated. I know this is a confusing issue.
liquidleaf
3/20/2007 8:36:19 PM
You are correct. Turns out my problem was that I was attempting to attachMovie
to the wrong object (I was using the "this" keyword incorrectly within the
onLoadInit of the MovieClipLoad listener, and of course in that case "this" was
the listener, and not the class object that the listener was contained within).
Doh.

It does work!

Thanks for the reply.
AddThis Social Bookmark Button