2 Replies Latest reply: Dec 9, 2010 5:21 AM by Petteri_Paananen RSS

    calling function from child to child?

    Petteri_Paananen Community Member

      Hi

       

      is it possible? I have a main.swf. I have loaded two child-SWFs into it, child1.swf and child2.swf....

      There´s a videoclip inside child1.swf, can I stop that video from child2.swf?

        • 1. Re: calling function from child to child?
          Hakan KIRIK Community Member

          yes, it's possible.

          You have to use the Loader.content for one child and cast it as a movieClip.

           

          Here is an example of how you can control a loaded child from the main.swf:

           

          http://www.flashdersi.com/flash/default.htm#ders61

           

          And that's what you have to do:

          in main.swf you add child1 like :

          ..

          ..

          var loader:Loader=new Loader();

          var child1:MovieClip;

          loader.contentLoaderInfo.addEventListener(Event.COMPLETE,fComp);

          function fComp(evt:Event)

          {

          child1=loader.content as MovieClip;

          }

          loader.load(new URLRequest("child1.swf"));

          addChild(loader);

          ...

          ..

           

          and in child2.swf use this code:

           

          MovieClip(this.parent).child1.videoClipName.stop();

           

          Maybe you need to use

           

          MovieClip(this.parent.parent.parent.......).child1.videoClipName.stop();   (depends on where you use the code in the child2.swf)

          I'm sure it wont work at the first try, just trace what you get with  this.parent or this.parent.parent  etc... and find the right expression.

          • 2. Re: calling function from child to child?
            Petteri_Paananen Community Member

            thanks, I´ll give it a try....=)