dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How to pass variables from root to component in flex

  1. #1
    Live And Let Live All sutar's Avatar
    Join Date
    Mar 2002
    Posts
    202

    How to pass variables from root to component in flex

    Hi All,

    Can anyone help me in getting variable values from root of application to my component.

    Ex.
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    	xmlns:bs="com.my.components.*">
       
       <mx:Script>
       <![CDATA[
       import mx.controls.Alert;
       
       public var userID:String = "Application.application.parameters.userId";
       
    
       ]]>
       </mx:Script>
       
       
       <bs:loginResultx="18" y="30"/>
       
    </mx:Application>
    and in my component
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    	>
       
       <mx:Script>
       <![CDATA[
       import mx.controls.Alert;
       private function test():void {
          Alert.show(Application.application.userId, "Flashvars"); 
       }
       ]]>
       </mx:Script>
    <mx:Button id="btnTest" label="Test" click="test()" />  
    
      
    </mx:Panel>

    I tried this but not working..

    ______________________________________________


  2. #2
    Interactive Developer
    Join Date
    Oct 2007
    Location
    Saint Louis
    Posts
    10

    An idea...

    Try removing the quotes from:

    "Application.application.parameters.userId"

    I believe you are setting your string to "Application.application.parameters.userId" instead of the value of Application.application.parameters.userId.

    Ben Bishop
    http://tdotblog.info

  3. #3
    Live And Let Live All sutar's Avatar
    Join Date
    Mar 2002
    Posts
    202
    Thanks


    Done, working

    ______________________________________________


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