2 Replies Latest reply on Feb 6, 2012 12:38 PM by JW1015

    using data between views

    JW1015

      Hi,

       

      I need to use the data from one view into a second view.

      The data is just a single string the name of a file eg: Alpha.swf

       

      In the second view I try to asign the data to a string variable but cannot figure out how to accomplish this.

      I can assign it to a label.text such as label.text="{data}";

       

      I need this string to resolve the path for a StageWebView.

       

      public var path:String = new File(new File("app:/assets/"+ data).nativePath).url; No this does not work?

       

      What am I doing wrong.

       

      John

        • 1. Re: using data between views
          Janadh

          Hi JW,

           

          On view1

           

          create an object;

           

               var obj:Object = new Object();

               obj.fileName = "File1.JPG";

                                                    navigator.pushView(view2,obj); //Call the second view

           

           

          On the second view2

          create a activate event from UI. This will be fired when you activate the view. On the event handler you can do whatever you want with the data.

           

          protected function view2_viewActivateHandler(event:ViewNavigatorEvent):void

                                        {

                                                  // TODO Auto-generated method stub

            Label1.label = data.fileName; //get the data from the object.

           

                                        }

           

          There may be other ways. this is all I know. Hope it helps.

           

          Cheers

          • 2. Re: using data between views
            JW1015 Level 1

            Hi,

             

            Thanks for the suggestion. however I still have the same problem.

             

            Getting the data from one view to the other is not the problem, it is trying to assign the data to a string that I have, be it an object or the data passed by pushview.

             

            I did try your method but the end result is the same:

             

            protected function stageView_viewActivateHandler(event:FlexEvent):void

             

                        {

             

                            // TODO Auto-generated method stub

             

                            manualname = data.fileName; //get the data from the object.

             

             

             

                        }

             

            public var path:String = new File(new File("app:/assets/"+ data.filename).nativePath).url;

             

            Still getting null object.