6 Replies Latest reply on Jan 5, 2007 1:50 PM by sl0beck

    Calling Function on a contained MovieClip

    flashgruven
      Not sure if this is possible however, my current project requires this functionality…

      Overview: user goes to webpage and based upon their profile, they get a Questionnaire as some content of their Flash Movie. The Questionnaire is an SWF file that is retrieved from the server and displayed by the containing Flash Movie.

      The < Next > button is on the Movie, not inside the Questionnaire. When the user presses the <Next> button, I need to get the user’s responses from the contained SWF questionnaire and send it to the server.

      Is it possible to add a function to the SWF, say GetResults(), which will gather the user’s input and return it back to the container Movie for further processing???

      In Java/C++/etc, I’d declare an interface and have all the Questionnaire SWFs implement this interface and could even check the type of the SWF (is a) and then invoke a function defined in the interface.

      Is there another way to do this in Flash if this won’t work??

      TIA,
      geo
        • 1. Re: Calling Function on a contained MovieClip
          arunbe Level 1
          Hi ,
          There is way to do this.
          You can use the Flash and JS communications.
          look this link
          http://www.abdulqabiz.com/files/JSFC/JSFCommunicator%20Library.htm
          • 2. Re: Calling Function on a contained MovieClip
            flashgruven Level 1
            Thanks arunbe, but I hope that isn't the answer... maybe I didn't describe my problem well.

            There are not 2 different SWF files in the same HTML page, but 1 SWF file and another contained with the SAME SWF file. From within the Parent SWF file, I use a MovieClipLoader to get the child SWF file from the server and then display it within the Parent SWF file in a MovieClip using loadClip()..

            I need some communication to happen between the parent and child SWFs in the Button Event Hanlder on release.

            Thanks again,
            geo
            • 3. Re: Calling Function on a contained MovieClip
              Level 7
              Do you simply need to have the results (in the child movie) sent to the
              server?
              If so, why can't you build a function called getResults of the type
              loadVars in the child movie and then call that function with the Next button
              that's in the parent movie (e.g., Next.onRelease = function() {
              childmovie.getResults} See the help files on the loadVars.

              Now if you're trying to pull the results from the child movie into the
              parent movie for processing of some sort before sending to the server that
              would be handled differently.

              "flashgruven" <webforumsuser@macromedia.com> wrote in message
              news:enlqps$47s$1@forums.macromedia.com...
              > Not sure if this is possible however, my current project requires this
              > functionality?
              >
              > Overview: user goes to webpage and based upon their profile, they get a
              > Questionnaire as some content of their Flash Movie. The Questionnaire is
              > an
              > SWF file that is retrieved from the server and displayed by the containing
              > Flash Movie.
              >
              > The < Next > button is on the Movie, not inside the Questionnaire. When
              > the
              > user presses the <Next> button, I need to get the user?s responses from
              > the
              > contained SWF questionnaire and send it to the server.
              >
              > Is it possible to add a function to the SWF, say GetResults(), which will
              > gather the user?s input and return it back to the container Movie for
              > further
              > processing???
              >
              > In Java/C++/etc, I?d declare an interface and have all the Questionnaire
              > SWFs
              > implement this interface and could even check the type of the SWF (is a)
              > and
              > then invoke a function defined in the interface.
              >
              > Is there another way to do this in Flash if this won?t work??
              >
              > TIA,
              > geo
              >
              >


              • 4. Re: Calling Function on a contained MovieClip
                sl0beck
                Greg's got it, spot on. You need the function to send the data in the child. call it from the button in the parent. It's quite simple really. You access the child using the handle (instance name) you gave it originally.
                • 5. Re: Calling Function on a contained MovieClip
                  flashgruven Level 1
                  Well, that was it... mostly.

                  The fact that I can just define a 'public' function in the SWF file and invoke it from the container is the correct path. I ended up defining a function GetResults():String which builds the results as a string and is then invoked from the Button.release event handler.

                  Then, from the container code, I can do some book keeping and then finally pass the results back to the server thru a WebService.

                  Thanks for all your help folks!!
                  • 6. Re: Calling Function on a contained MovieClip
                    sl0beck Level 1
                    Yup, that as they say is the ticket.