4 Replies Latest reply on May 17, 2008 5:48 AM by slaingod

    Using Flash variable data within Flex 3.0

    b_cedergren
      I am trying to access the variable that I have in my Flash swf and use it within Flex to send to the server-script. How is this accomplished?
        • 1. Re: Using Flash variable data within Flex 3.0
          Gregory Lafrance Level 6
          I didn't think you could have AS in Flash SWF brought into Flex, or at least it was ignored. You can access other Flex app swf AS though.
          • 2. Re: Using Flash variable data within Flex 3.0
            b_cedergren Level 1
            I'm not sure if this makes any difference, but I can activate the function within the embedded swf and have it output to the Flex console.
            • 3. Re: Using Flash variable data within Flex 3.0
              ntsiii Level 3
              You can have a Flash swf in Flex as long as they use the same version of ActionScript. Actually, you can use a Flash 8 swf in Flex 2-3, but it is difficult to communicate with it.

              But in this case there should be no problem.

              You can access any public property of the loaded swf throught the SWFloader.content property.

              There are some timing issues if you attempt this immediately on load. I have an example on www.cflex.net that shows how to do that.

              But if the swf is fully loaded before you attempt to communicate iwth it, say on a user click, there should be no problem.

              Tracy
              • 4. Using Flash variable data within Flex 3.0
                slaingod Level 1
                Generally you can do this by creating an AS file for your SWF, and setting it in the Publisher settings.

                For example: If you name put 'example' in the Action Script setting box in the publisher settings, it will look for a file called example.as.

                Your example.as would look like:
                package
                {
                import flash.display.MovieClip;

                public class example extends MovieClip
                {
                function example ():void
                {

                }

                public function start():void
                {
                intro2.gotoAndPlay(2);
                }

                }
                }

                except insteead of start() you would have your method read and return the data you needed. You may need to give some of your flash objects instances names so you can get to them more easily.

                You would need to wait on the complete event in Flex, then you could use
                mx:Image id="myexample"...
                and

                (myexample.content as MovieClip).start()