1 Reply Latest reply on Jul 2, 2010 5:21 AM by nishadmusthafa

    SWFLoader communication in both directions

    avsesis Level 1


      I have a situation where I have a flash builder file that I use to store information to a database.

      I also have a flash swf where I am colouring irregular shapes. I can send information to the flash file from the flashbuilder file using SWFLoader but I need to find what colours were chosen and which panels the colours were applied in the flash file so that I can store this information in the database from the flashbuilder file. From my reading of the subject, it would appear that SWFLoader only works in one direction.

      Can anybody verify this and offer me an alternative method to receive information from the loaded swf file please.

        • 1. Re: SWFLoader communication in both directions
          nishadmusthafa Level 2



          If i had a function like this in my SWF(conveniently named mySWF.swf)


          function getValue():String
              return "5";


          And if the code on my flex app was like this.


                      private var swfLdr:SWFLoader;
                      private var childSwf:MovieClip;
                      protected function application1_creationCompleteHandler(event:FlexEvent):void
                          // TODO Auto-generated method stub
                          swfLdr = new SWFLoader();
                          swfLdr.horizontalCenter = 0;
                          swfLdr.verticalCenter = 0;
                          swfLdr.source = "mySWF.swf";
                          swfLdr.addEventListener(Event.COMPLETE, swfLoaded);


                      private function swfLoaded(event:Event):void{
                          swfLdr.removeEventListener(Event.COMPLETE, swfLoaded);
                          childSwf = new MovieClip();
                          childSwf = event.target.content;
                          var k=childSwf.getValue();



          Then the value of k at the end of the SWFloaded function is "5". This does provide a form of the host SWF getting values from the loaded swf. Similarly, values can be passed as parameters to functions too. Pardon me if i misunderstood your query. Was this what u were looking for?



          1 person found this helpful