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

flash actionscript : Problems with MovieClipLoader onLoadInit


CaioToOn!
1/4/2007 6:22:49 PM
Hello everybody.

I'm having problems with the MovieClipLoader class.

The onLoadInit is broadcasted before the target is indeed initialized.

Searching about this, I founded at the macromedia documentation that other
developers are having the same problem, but nobody sends a answer.

Does anybody know how to resolve this?!

Thanks.
CT.
kglad
1/4/2007 6:38:01 PM
CaioToOn!
1/4/2007 6:44:39 PM
Hi, Kglad.

As I said, the problem is that the MovieClipLoader broadcast the onLoadInit
event before the loaded movie is completely initialized when this have many
methods.

For exemple, I created a movie with many methods called Movie1.swf

Then I created de Main.swf

At the Main.swf I load the Movie1.swf with MovieClipLoader. What is happening
is that on the onLoadInit event I traced any of the methods and the return is
undefined. But if I delay, it returns [type Function].

Was I clear? If not, I can upload a sample.
Thanks,
CT.
kglad
1/4/2007 7:00:22 PM
CaioToOn!
1/4/2007 7:40:48 PM
All the methods are in an AS file that is included in the first frame of
Movie1.swf, but no methods are using _root.methodName

What I tried is like the following sample:

At the main.swf I have:

var obList:Object = new Object();
obList.onLoadInit = function(ob)
{
trace (ob.anyMethod);
}

var mcLoader:MovieClipLoader = new MovieClipLoader()
mcLoader.addListener(obList);

this.createEmptyMovieClip("movie",this.getNextHighestDepth());
mcLoader.loadClip("Movie1.swf",movie);


Doing that, the return is undefined, what means that the anyMethod at the
Movie1.swf is not yet initialized.

Obs.: Excuse me by the poor english, I'm not American, and learned English by
myself.



kglad
1/4/2007 7:48:54 PM
if you have a function (anyMethod) defined on the main timeline of Movie1.swf, use:





var obList:Object = new Object();
obList.onLoadInit = function(ob)
{
trace (ob.anyMethod());
CaioToOn!
1/4/2007 7:58:50 PM
The question is that the method don't exists yet. When I traced, I really tried
to trace de object and the return should be [type Function]

If I trace like trace(ob.anyMethod()); I will have the return of the function,
but I traced the Function object and it return undefined, meaning that it not
exists. Otherwise it return [type Function]

As I said, if I delay with a setInterval, for exemple, it traces [type
Function], meaning that at this moment the movie is completely initialized.


kglad
1/4/2007 8:46:38 PM
post a link to the flas that display the issue.

CaioToOn!
1/5/2007 3:11:17 PM
Hi, Kglad.

Thanks by the effort.

I was answered at the Adobe Brazil Forum.

The solution can be acessed at the following link:

http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=25&catid=20
6&threadid=1229605&enterthread=y

Thank you again.
CT.
kglad
1/5/2007 3:27:02 PM
i dont believe there is a problem with onLoadInit(). i suspect you're trying
to access something that isn't available when the first frame of the main
timeline in your external swf loads.

post a link to your flas if you think there is something that is defined in
the first frame of the main timeline and not available onLoadInit().
CaioToOn!
1/5/2007 3:39:42 PM
As you mentioned this subject, at trust, the error occurs when I have a Shared
Library at the external movie. I founded a solution by loading the same shared
library at the main movie and using a textbox to force the load of the SL at
the first frame of the main movie. It works, but that other solution is more
inteligent and is the solution that the own Flash components uses.

I will upload the files and contact here.

CT.
AddThis Social Bookmark Button