3 Replies Latest reply on Feb 22, 2007 4:12 PM by 187_2007

    Passing a simple string

      Main.mxml - main app
      TabMain.mxml - component called from Main.mxml via component
      Banner.mxml - component called from TabMain.mxml via component

      So it looks like this:

      --B Component
      ---C Component

      I want to be able to pass a string from A to C or from Main to Banner...

      What is the best way to do this?

      Here is what I am doing..


      Click on the first tree node.... It brings up the tabs on the right... I want to be able to send the name "CBS NEWS" to Site Spec Reqs.

      Is it best to send the data through the components like this?
      <m:TabMain mySelectedNode ="{sharedData}"/>

      or another way?

        • 1. Re: Passing a simple string
          jlingwai Level 1
          I would do it one of two ways.....
          use a global variable class.....this way you could populated the value from the main app and retrieve it in the children

          lets say you want to pass the info on a click function(clickNav) in the main to a function(clickInfo) in the banner component assuming the following name convention

          <components:TabMain id="cmpTab"/>
          <components:Banner id="cmpBanner"/>

          public function clickNav():void{

          Hope this helps

          • 2. Re: Passing a simple string
            phi2265 Level 1
            shared object

            public var sharedVariables:SharedObject = SharedObject.getLocal("variables");
            (this will need to be decalred in each script)
            to set or retrieve a value you do this:
            sharedVariables.data.myVariable = new String();
            sharedVariables.data.myVariable = 'string here';

            on a further note: SharedObjects are written to the local file system, the user's/client's file system, useful if you need to store keep settings for a user or something like that. Also, getLocal will create the file if it doesn't exsist already, if it does.. it just reads it. Read the docs on SharedObject.

            • 3. Passing a simple string
              187_2007 Level 1
              OKay. I did it the Shared Object way... SWEET!!! Thanks for the info.... Okay... NOW.... I take that Shared Object (which is a string) and I pass it to my REMOTEOBJECT (in init function). When the remote object returns (myResult) I take the resultset and stuff it into an ArrayCollection. Then I trace it out.. Everything traces out fine... I then click a BUTTON and it calls my TEST function... I simply trace the ArrayCollection out again, just like I did in my (myresult) function... NOthing... There is nothing in my ArrayCollection when I click the BUTTON (test function is ran). Why is that?

              public function init():void{

              public function myresult(event:ResultEvent):void{
              var result_Array:Array = event.result as Array;
              myArrayofStructs.source=event.result as Array;


              private function test():void{