2 Replies Latest reply on Nov 11, 2008 12:51 PM by Peter Lorent

    Comunication and events: Flex Builder 2 with Flash CS3

    Jorge_EdOardo
      Hey hello...well, my question is: how can i comunicate Flex Builder 2 with Flash CS3?

      this is my code on Flex Builder 2:
      <mx:Script>
      <![CDATA[
      import mx.controls.*;
      import mx.events.*;
      public function CargaCompleta(e:Event):void
      {
      try
      {
      e.target.content.objeto_salida.addEventListener(Event.COMPLETE,uno);
      }
      catch(er:Error) { Alert.show(er.message,"Error"); }
      }
      public function uno(e:Event):void
      {
      try
      {
      s1.content["objeto_salida"].removeEventListener(MouseEvent.CLICK,s1.content["Finaliza"]);
      s1.source = null;
      s1.source = "recursos/reactivos/208M-1R.swf";
      }
      catch(er:Error) { Alert.show(er.message,"Error"); }
      }
      ]]>
      </mx:Script>
      <mx:SWFLoader id="s1" width="278" height="251" complete="CargaCompleta(event)" source="recursos/interactivos/208M-1I.swf">
      </mx:SWFLoader>

      and when it change from one file to another, on the event "Complete" for the SWFLodar, an error happend

      TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.
      at 208M_fla::MainTimeline/frame1()

      Hope somebody can help me...for your time thanks...
        • 1. Re: Comunication and events: Flex Builder 2 with Flash CS3
          Level 7

          "Jorge EdOardo" <webforumsuser@macromedia.com> wrote in message
          news:gfcfcr$9s2$1@forums.macromedia.com...
          > Hey hello...well, my question is: how can i comunicate Flex Builder 2 with
          > Flash CS3?
          >
          > this is my code on Flex Builder 2:
          > <mx:Script>
          > <![CDATA[
          > import mx.controls.*;
          > import mx.events.*;
          > public function CargaCompleta(e:Event):void
          > {
          > try
          > {
          > e.target.content.objeto_salida.addEventListener(Event.COMPLETE,uno);
          > }
          > catch(er:Error) { Alert.show(er.message,"Error"); }
          > }
          > public function uno(e:Event):void
          > {
          > try
          > {
          >
          > s1.content["objeto_salida"].removeEventListener(MouseEvent.CLICK,s1.content["Fin
          > aliza"]);
          > s1.source = null;
          > s1.source = "recursos/reactivos/208M-1R.swf";
          > }
          > catch(er:Error) { Alert.show(er.message,"Error"); }
          > }
          > ]]>
          > </mx:Script>
          > <mx:SWFLoader id="s1" width="278" height="251"
          > complete="CargaCompleta(event)"
          > source="recursos/interactivos/208M-1I.swf">
          > </mx:SWFLoader>
          >
          > and when it change from one file to another, on the event "Complete" for
          > the
          > SWFLodar, an error happend
          >
          > TypeError: Error #1009: No se puede acceder a una propiedad o a un m?todo
          > de
          > una referencia a un objeto nulo.
          > at 208M_fla::MainTimeline/frame1()
          >
          > Hope somebody can help me...for your time thanks...

          http://weblogs.macromedia.com/pent/archives/2007/04/using_actionscr_1.html


          • 2. Re: Comunication and events: Flex Builder 2 with Flash CS3
            Peter Lorent Level 2
            What exactly are you trying to accomplish?
            When the complete event fires on the SWFLoader you can simply retrieve a reference to the loaded swf.

            public function CargaCompleta(e:Event):void
            {
            var clip:MovieClip = s1.content as MovieClip;
            // and then you can register event listeners on the loaded swf
            clip.addEventListener("clicked", clickHandler);
            }