4 Replies Latest reply on Mar 6, 2008 3:44 PM by ntsiii

    Passing array result set between Viewstack pages

      Hi, all.

      I want to use an array result in various Viewstack pages. So the main application run a RemoteObject call, gives the result to a function that makes the area. I then want to call the array result from other pages in the Viewstack. Is there a way to reference from the other pages? I cannot seem to do it. Thanks.

      I would add my code, but I cannot find the Attach Code thing they are talking about.
        • 1. Re: Passing array result set between Viewstack pages
          ntsiii Level 3
          See my response in the post titled ViewStack.
          • 2. Re: Passing array result set between Viewstack pages
            ericbelair Level 1
            One easy way to do this would be to store the Array Result in a public variable in the main application. Here's how to do it in ActionScript:

            --- Main Application ----

            public var arrayResult:Array;

            // The result handler of the Main Application....
            private function resultHandler(event:ResultEvent):void
            arrayResult = new Array(event.result);

            --- ViewStack Child ---

            for each (var object:Object in parentApplication.arrayResult)
            • 3. Re: Passing array result set between Viewstack pages
              binkerboy Level 1
              Eric and Tracy,

              Thanks for these suggestions. I will try them. I think the real issue is knowing HOW to call back to the "parentApplication" (whatever that is. ;) I just learned something new, thanks).

              I do appreciate the more in-depth how-to's, having come from the procedural world of CF. Like many starting to use Flex, I sort of fell into this field, having no real background or formal programming experience and learning by example is really useful. I mainly did business development before getting into Flex programming.

              Like learning to talk in another country that also uses sign language and clicks in the vocabrulary, we have to learn a whole new vocabulary and even way of thinking about what and how we say things. Again, thanks for the patience and time.

              Gary McNeel
              Struggling Flex Coders Anonymous Member Since 2007
              • 4. Re: Passing array result set between Viewstack pages
                ntsiii Level 3
                Yes, it can be messy, because there is more than one way to do most anything. For accessing members in the "ancestor" chain, you can use: parent, parentDocument, parentApplication, and Application.application.

                Knowing which to use just takes experience. Here is my summary:

                parent: the immediate component parent. eg. TextInput -> parent canvas/

                parentDocument: The containing component file. TextInput -> parentCanvas -> Viewstack ....->...>...MyComponent.mxml(or .as)

                parentApplication: TextInput -> ......-> [first application tag]. This is NOT always the top-level application, because an app can be loaded in SWFLoader.

                Application.application: ALWAYS the top-level application.