A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Pass a var from Flex To swf?

  1. #1
    Member
    Join Date
    Sep 2010
    Posts
    73

    Pass a var from Flex To swf?

    Can any one help me learn how to pass a var from flex application to a swf file that is on my server?


    Actionscript Code:
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx"
                           creationComplete="init()" currentState="Login"
                           width.Main="1400" height.Main="800">
        <fx:Style source="WiiStream.css"/>
        <s:states>
            <s:State name="Login"/>
            <s:State name="Main"/>
        </s:states>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import com.facebook.graph.FacebookDesktop;
               
                private function init():void {
                    FacebookDesktop.init("186852251378211" , handelLogin);
                }
                public function handelLogin(session:Object, fail:Object):void {
                if(session != null)
                {
                    currentState = "Main";
                    userImage.source = FacebookDesktop.getImageUrl(session.uid, 'large');
                    userName.text = session.user.name;
                    userId.text = session.uid;
    //////////////////////////////////////////////////////////////
    I WANT TO LEARN HOW I CAN PASS THE VARS RO A SWF FILE
    I WOULD LIKE TO GET ALL DATA IN MY FLEX AIR THEN SEND THEM TO MY SWF FLASH PROJECT!

    THIS IS THE FIRST ONE I WANT TO WORK ON HOW TO PASS A STRING
    TO MY SWF FILE!
                    var foo:String = session.uid;
    //////////////////////////////////////////////////////////////
                }
                }
                private function doLogin():void {
                    FacebookDesktop.login(handelLogin, []);
                }
                private function doLogout(): void{
                    FacebookDesktop.logout();
                    currentState ="Login";
                }
            ]]>
        </fx:Script>
        <s:Image id="userImage" includeIn="Main" left="-123" top="-19" width="100" height="100"/>
        <s:Label id="userName" includeIn="Main" left="-111" top="106" width="100" fontSize="18"/>
        <s:Button includeIn="Main" click="doLogout()" right="10" top="10" label="Logout"/>
        <s:SWFLoader id="wii" includeIn="Main" left="310" top="147" width="838" height="489"
                     source="http://wiistream.net/index.swf"/>
        <s:Label id="userId" includeIn="Main" x="-220" y="179" width="214" fontSize="18"/>
        <s:SWFLoader id="index" includeIn="Login" x="0" y="0" source="http://wiistream.net/flash/index.swf"/>
        <s:Button includeIn="Login" label="Login To Facebook" click="doLogin()" horizontalCenter="0"
                  verticalCenter="8"/>
    </s:WindowedApplication>


    Then I need to learn how to GET the VAR THat is passed into the swf file some get method from FLEX?
    WiiStream A Social Movie Network Version 0.1.1 Demo Testers Aproved http://wiistream.net/WiiStream.exe

  2. #2
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    whoa I don't understand flex compiles to a .swf as does traditional flash. So do you need to pass variable data between two .swf ? or are you trying to pass a variable at compile time? If its two .swf I believe you use local connection object although I could be wrong its been several months since I used it. At any rate do a google search for passing data between AS 3.0 swf to verify if this is your intention. Be warned I don't know if you can pass data between a flex .swf and a traditional .swf. Please let me know if you pursue it. I'd love the answer.
    ~calmchess~

  3. #3
    Member
    Join Date
    Sep 2010
    Posts
    73
    I haven't found anything to solve this yet, I was hoping I could pass the var from flex into a flash pro swf, I was wanting to gather all the data from Facebook in flex then load a flash pro swf that gathered the vars from flex into flash pro swf. Thats the goal. but nothing I do seems to work yet.
    WiiStream A Social Movie Network Version 0.1.1 Demo Testers Aproved http://wiistream.net/WiiStream.exe

  4. #4
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    I don't know what you mean by pass a var from flex into flash pro swf exactly how were planning to get facebook information into flex ? flex is a programming IDE which helps you structure,write and compile code into byte code which can be run in the flash player. It knows nothing about external services or data untill its compiled. I suggest you check out the facebook API/SDK which can help you build a RIA/Application which can communicate and manipulate face book data.

    http://code.google.com/p/facebook-actionscript-api/
    ~calmchess~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center