8 Replies Latest reply on Feb 12, 2012 10:20 PM by sampsonatr1964

    Trying to get Data from a classic input field in a movie clip

    sampsonatr1964

      I’m working on a basic CMS project (for self learning purposes) and I’m stuck on something trying to get data from an input text inside of a movie frame.  The code will work with the homeUpdate_btn on the same level as the home_input_txt.

       

      When I run the (swf) the homeUpdate_btn doesn’t show because it’s on the root level not the parent level. (it’s on the inside of the movie clip with the home_input_txt). 

       

      So if I put the homeUpdate_btn on the parent level (I hope I getting my levels right).  Then the button is not able to get the data of the home_input_txt field that is on the root level.

       

      Let me try this again…you can see the Classic home_input_txt from the parent level (outside the movie clip and make changes), but you can’s see the homeUpdate_btn from that level.  So to see the homeUpdate_btn I.... put it on the parent level.  Now how to I update and get data on the root level from the home_input_txt ....inside the movie clip?  

       

      __________________________________________________________________________________________ _____________________________

       

      I think this is the line that the update data is coming from…. which is the input text:    homeEdit_variables.home_body = home_input_txt.htmlText;

       

       

      ________________________________________________________________________

       

       

      Question:  homeUpdate_btn doesn’t show on the inside of movie clip when I run it.

       

      ______________________________________________________________________

       

      Entire Action Script for "Udate Home Page".  (again inside a movie clip)

       

      stop();

      // restrict what characters the user can type into the input text field

      home_input_txt.restrict = "A-Za-z 0-9,.?!$&=@_";

      // put current homepage data into the input text field for editing

      home_input_txt.htmlText = homePageText;

       

      // Assign a variable name for our URLVariables object

      var homeEdit_variables:URLVariables = new URLVariables();

       

      //  Build the varSend variable

      var homeEdit_varSend:URLRequest = new URLRequest("cms_control_file.php");

      homeEdit_varSend.method = URLRequestMethod.POST;

      homeEdit_varSend.data = homeEdit_variables;

       

      // Build the varLoader variable

      var homeEdit_varLoader:URLLoader = new URLLoader;

      homeEdit_varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

      homeEdit_varLoader.addEventListener(Event.COMPLETE, completeHandler_home_edit);

       

      // Handler for PHP script completion and return

      function completeHandler_home_edit(event:Event):void{

                 

         gotoAndStop("home");

                             

      }

      // Add an event listener for the submit button and what function to run

      homeUpdate_btn.addEventListener(MouseEvent.CLICK, updateHomePage);

       

      // Validate form fields and send the variables when submit button is clicked

      function updateHomePage(event:MouseEvent):void{

                 

                              // Ready the variables for sending

                              homeEdit_variables.sendRequest = "update_home_page";

                              homeEdit_variables.home_body = home_input_txt.htmlText;

                              // Send the data to the php file

                              homeEdit_varLoader.load(homeEdit_varSend);

       

      }

        • 1. Re: Trying to get Data from a classic input field in a movie clip
          kglad Adobe Community Professional & MVP

          does home_input_txt exist when you click homeUpdate_btn?  ie, it's visible when you click the button?

           

          if yes, is home_input_txt on the parent timeline of the timeline that contains homeUpdate_btn.  if yes, use:

           

          parent.home_input_txt.htmlText

           

          to reference it's htmlText property.  if it's on the parent.parent timeline, use:

           

          parent.parent.home_input_txt.htmlText

           

          etc

          • 2. Re: Trying to get Data from a classic input field in a movie clip
            sampsonatr1964 Level 1

            The home_input_txt doesn't exist on the same frame when homeupdate_btn is clicked, because the button is outside the movie clip on another frame....in order to see it when running the swf.  so I will try the parent.parent.home_input_txt.htmlText    I will let you know if it works.   Thanks for the help....I really appreciate it :-)

             

             

            Is there a way to make the home_input_txt visible throughout your swf...so I can reference it and get the update data without parent.parent or is that the only way?  Just curious.  I'm a beginner at action script, but I love it.  I've done html, but it's nothing like Flash.

            • 3. Re: Trying to get Data from a classic input field in a movie clip
              kglad Adobe Community Professional & MVP

              if home_input_txt no longer exists when that button is clicked, assign a variable to the text value AFTER text is entered into that textfield.  the variable will persist even after the textfield no longer exists:

               

              var home_text:String; 

              home_input_txt.addEventListener(Event.CHANGE,changeF)

               

              function changeF(e:Event):void{

              home_text= home_input_txt.htmlText; 

              }

              • 4. Re: Trying to get Data from a classic input field in a movie clip
                sampsonatr1964 Level 1

                The action script below (suggested) works..... if the "home_input_txt" is on the same "Timeline" of the "homeUpdate_btn", but I'm needing to retreive the data from the "home_input_txt" that is on another "Timeline" inside of the movie clip.  The "homeUpdate_btn" is on top of the movie clip.

                 

                Is there a reason why "home_input_txt" (in the script below) can't be read from another "Timeline" within the "SWF"?

                 

                Again I'm a beginner so hopefully I'm saying all of this right :-)

                 

                 

                 

                //////////HERE IS THE SUGGESTED SCRIPT

                 

                var home_text:String;

                home_input_txt.addEventListener(Event.CHANGE,changeF)

                 

                function changeF(e:Event):void{

                home_text= home_input_txt.htmlText;

                }

                • 5. Re: Trying to get Data from a classic input field in a movie clip
                  kglad Adobe Community Professional & MVP

                  yes, so now:

                   

                   

                  use:

                   

                  parent.home_text

                   

                  or if it's on the parent.parent timeline, use:

                   

                  parent.parent.home_text

                   

                  etc

                  • 6. Re: Trying to get Data from a classic input field in a movie clip
                    sampsonatr1964 Level 1

                    Where would I put the parent.home_text?    Where the in the action script from your suggestion?  

                     

                    It's giving me this error message each time:  Below when I use the parent.home_text

                     

                     

                    Error Message:    Symbol 'page 1 edit', Layer 'action', Frame 1, Line 1 1086: Syntax error: expecting semicolon before dot.

                     

                    ______________________________________________________________________________________

                     

                    var parent.parent.home_text:String; 

                    home_input_txt.addEventListener(Event.CHANGE,changeF)


                    function changeF(e:Event):void{

                    parent.parent.home_text= home_input_txt.htmlText; 

                    }

                     

                     

                    Sorry I'm not getting it :-(    That's a beginner for you.

                    • 7. Re: Trying to get Data from a classic input field in a movie clip
                      kglad Adobe Community Professional & MVP

                       

                      ////////// use this on the timeline/frame where home_input_txt exists

                       

                      var home_text:String;

                      home_input_txt.addEventListener(Event.CHANGE,changeF)

                       

                      function changeF(e:Event):void{

                      home_text= home_input_txt.htmlText;

                      }

                       

                       

                      ///////// use this where your button exists:

                       

                      homeUpdate_btn.addEventListener(MouseEvent.CLICK, updateHomePage);

                       

                      // Validate form fields and send the variables when submit button is clicked

                      function updateHomePage(event:MouseEvent):void{

                                 

                                              // Ready the variables for sending

                                              homeEdit_variables.sendRequest = "update_home_page";

                                              homeEdit_variables.home_body = parent.home_txt // or parent.parent.home_txt etc

                                              // Send the data to the php file

                                              homeEdit_varLoader.load(homeEdit_varSend);

                       

                      }

                       

                      • 8. Re: Trying to get Data from a classic input field in a movie clip
                        sampsonatr1964 Level 1

                        I'm getting this error message:

                        Symbol 'page contents', Layer 'actions', Frame 25, Line 44 1119: Access of possibly undefined property home_input_txt through a reference with static type flash.display:DisplayObjectContainer.

                         

                         

                        _______________________________________________________________

                         

                        //////  mc_edit is the name for the movie clip

                        /////  So I thought I would tell it to find.... the home_input_txt.htmlText....in the movie clip container.

                        ////// I changed the line below in the action script where the button is.

                        ______________________________________________________________________________

                         

                        homeEdit_variables.home_body = mc_edit.home_input_txt.htmlText

                         

                         

                        __________________________________________________________________________

                         

                        it worked :-)

                         

                         

                        It may not be the right way but it fix the problem giving me a severe headache...LOL

                         

                        Thanks for all your quick responses.  You have kept me motivated