1 Reply Latest reply on Oct 3, 2008 8:46 AM by Peter Lorent

    Passing data from a SWF to Flex

    cputnam14 Level 1
      Is there a way to pass data from a swf back to flex?

      I have a flex app with an embeded swf that is a map of the USA. When a user clicks a state, I want to pass the state to flex. I don't have a clue how to start doing that, or if it is even possible. Any help would be greatly appreciated
        • 1. Re: Passing data from a SWF to Flex
          Peter Lorent Level 2
          From a loaded swf (AS3 that is) with some limitations. You can dispatch events from the loaded swf using code on the timeline of the loaded swf. In Flex, use a complete handler on the SWFLoader and retrieve a reference to the loaded swf. Then register event listeners on the swf.

          private function onLoadCompleted():void
          var clip:MovieClip = mySWFLoader.content as MovieClip; //gets a reference to the root timeline
          clip.addEventListener("clicked", clickHandler);

          <mx:SWFLoader id="mySWFLoader" source="my.swf" complete="onLoadCompleted()"/>