7 Replies Latest reply on Aug 1, 2007 9:16 PM by kglad

    Problem with function arguments

    drzeller
      I am having a problem with arguments to a function not working. In the attached example, the values passed to the function are never reflected within the function.

      Can any one tell me what I am doing wrong?

      Thanks,
      David
        • 1. Problem with function arguments
          _name Level 1
          * the params within your function displayPic should only be listed by their var names, not their var names and their data types *

          copy and paste the code i have written you below into a new flash document on frame one of the _root, observe the code, test the movie, and check your output window. you will see how passing arguments to a function is as simple as 1, 2, 3.
          • 2. Re: Problem with function arguments
            drzeller Level 1
            Thank you. Oddly, the examples I was following all included the type.

            Much appreciated.

            David
            • 3. Re: Problem with function arguments
              kglad Adobe Community Professional & MVP
              there's no problem with your first code, there's no problem with the trace() results and there's no problem typing function parameters.

              what did you think was going wrong?
              • 4. Problem with function arguments
                _name Level 1
                kglad is right, there is no problem with including the data type of a var within a function's parameters. in fact, you can even define a variable, including its data type, to be used within a function specifically within that function's params. i told you not include the data types of your vars within your function's params because you had already defined them at the top of your code, so i felt there was no need to to do it again. i should have been more clear about why i told you to do that - my apologies.
                • 5. Re: Problem with function arguments
                  drzeller Level 1
                  Thanks, _name.

                  klad, the trace results were not correct. The second results should have reflected the values passed into the function. The process worked as expected when I removed the data types from within the function definition.

                  D.
                  • 6. Problem with function arguments
                    _name Level 1
                    hey drzeller,
                    i just copied and pasted the original code you attached to this thread into flash and kglad is right. there is no problem with any of it. i didn't check your values before i altered your code originally, i just assumed they were outputting the values you posted. if you will copy and paste your original code back into flash and check the output window you will see what kglad is talking about.
                    just so you know, all the advice i've ever seen in this forum from kglad has been spot on. definitely use his advice.
                    • 7. Re: Problem with function arguments
                      kglad Adobe Community Professional & MVP
                      i don't see any problem. i believe you may be confused by your own trace statements: your first trace statement is for the 2nd parameter and your 2nd trace statement is your first parameter. that may be causing some confusion.