3 Replies Latest reply on Jul 19, 2007 5:57 PM by ntsiii

    Passing Variables FROM Flex to Flash

      I am looking on how to create a variable within FLEX and make it where it can be read directly in FLASH.

      Any help on this would be great

        • 1. Re: Passing Variables FROM Flex to Flash
          rotoole Level 1
          dispatching the event and setting the "prog" var to the % in which i want my meter to display

          //heres the flex side
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" horizontalScrollPolicy="off" verticalScrollPolicy="off" backgroundColor="#000000" width="100%" height="100%">
          [Event(name="setMeter", type="flash.events.Event")]

          public function populate(mySize:Number):void
          prog=mySize * 10;
          dispatchEvent(new Event("setMeter", true));


          <mx:SWFLoader source="meter.swf" width="100%" height="100%" id="mtr1"/>
          <mx:Number id="prog"/>

          what im doing here is adding an event listener from my embedded swf (4 parents deep).

          then setting a var(myFlex:Object) to the movieclip.parent.parent.parent which would be the flex movieclip

          then actually grabbing that var "prog" to figure out what level to set the meter.

          //heres the flash side
          var mm:MovieClip = this;
          this.parent.parent.parent.parent.addEventListener("setMeter", cHandler);

          function cHandler(event:Event):void
          var myFlex:Object = mm.parent.parent.parent;

          i know there are definitely better ways to do this but it works for me. i have used the external interface class and local connection class but this works pretty well for me too if the vars you need aren't too ambiguous. im currently using the external interface with the yahoo maps api and it works really well but im having trouble using more than one external interface instance in the same app....so i went this route for some of the newer simpler ones .


          • 2. Re: Passing Variables FROM Flex to Flash
            GhostfromTexas Level 1
            basically what we are doing is storing a string of text on the flex side, and then sending it to the flash side to display. That's it in it's simplistic form.
            • 3. Re: Passing Variables FROM Flex to Flash
              ntsiii Level 3
              How are the Flex app and the flash swf related? ie, what is the component architecture.