all groups > flash actionscript > october 2007 >
You're in the

flash actionscript

group:

Loaded .swf comunication with loader .swf


Loaded .swf comunication with loader .swf Ardy15jan
10/31/2007 8:37:46 PM
flash actionscript:
Hi, everyone!
I have a big problem...
I`ve loaded a .swf file using a 'flash.display.Loader'. The .swf contains a
button. When the user clicks the button, I want the loader .swf to execute a
certain function that I defined within it.
In AS2, I would have accomplished this by means of '_level0.functionName();'.
In AS3, however, I can`t fiind a way to comunicate with the parent .swf....
Please help me!
Thank you!
Re: Loaded .swf comunication with loader .swf kglad
10/31/2007 8:56:27 PM
you can reference the main timeline from any display object (probably your
loaded swf's parent loader) by using the display object's root property. to
reference a function on the main timeline, cast that root property as a
movieclip and use dot notation just like as2.
Re: Loaded .swf comunication with loader .swf Ardy15jan
10/31/2007 9:08:22 PM
Thanks, kglad!
I`ve already tryed just that, but my application is a little bit more
complicated than I mentioned above and when I got errors I thought it wasn`t
the way to go. Now at least I know where to start from.
Thanks again!
Re: Loaded .swf comunication with loader .swf Ardy15jan
10/31/2007 9:18:35 PM
Ok, so I`ve actually made some progress! I`m getting new errors.
The error says: "TypeError: Error #1006: initPasswordInput is not a function.
at intro6_fla::KnockArtLogoAnimation6_7/onRollOver2()", where
[i]initPasswordInput()[/i] is the function on the loader .swf
What`s that supposed to mean? I`ve defenetly defined the function.
PS: I`m using a document class for the loader swf, but I`ve tryed a simpler
example and it tells me the same thing...
Re: Loaded .swf comunication with loader .swf kglad
10/31/2007 9:21:51 PM
you're welcome.

your code in the external swf must be on some movieclip's timeline. and that
movieclip must be in the display list (ie, on-stage) for its code to execute.

so, from any timeline in your external swf, you can use this.root to get to
the external swf's main timeline. then the parent of that external swf main
timeline will be your loader (in the loading swf). and the root property of
that loader will be the loading swf's main timeline. so, you can always use:



MovieClip(this.root.parent.root).yourF();

// to execute yourF() on your loading swf's main timeline from any timeline in
your external swf.
Re: Loaded .swf comunication with loader .swf Ardy15jan
10/31/2007 9:25:12 PM
Thanks a milion, kglad!
Re: Loaded .swf comunication with loader .swf kglad
10/31/2007 9:33:48 PM
AddThis Social Bookmark Button