7 Replies Latest reply on May 8, 2006 7:33 AM by kglad

    Please Help - Functions passing parameters problem

    rring
      Hi
      Im really stumped, iI hope someone can help. My code is attached.

      My problem is that Im trying to set up conditions for "holder.clip.my_btn.onRelease" which is a subnavigation button that is embedded in a loaded ContainerSWF. When I click "holder.clip.my_btn" my trace() statement says that ALL conditional statements in the code are true. Thats not what I want. I want the Songs() function to have a unique Category ID=1 and unique ClipCategory that "holder.clip.my_btn" can see and execute in the conditional script.. That way "holder.clip.my_btn" knows when to load songs, or when to load games based on the Category ID and Clip Category that is sent from the songs_btn or games_btn in the main nav. Vice Versa I want the games_btn in the function Games() to pass a Category ID=2 and unique clip ID, so that "holder.clip.my_btn" can run the conditionals and see that games, not songs, should be loaded.a

      Heres the setup:
      1. When timeline hits a specific frame, the function AllTheButs() is called.
      2. AllTheButs() passes parameters, including unique Category IDs to the Songs() function and the Games() function. Those two functions enable the user to click on either the songs_btn or games_btn in the main nav. If "songs_btn" in Songs() is clicked, a Songs-specific Container Movie loads into a holder.clip, and that Container Movie will see the Songs CatID and Songs ClipCat parameters that AllTheButs() sent to Song();

      3. holder.clip contains a subnav -- "my_btn" and " my_btn2 . When holder.clip loads "ContainerSWF" a function called _parent._parent.internalmovies() is called back in my Main Movie. The result is that internalmovies() in my main movie can control my_btn and my_btn2 in the holder.clip/ContainerSWF. Thats what I want, but those sub nav buts need to know when to load songs, and when to load games based on the Cat ID and Clip Categories passed to them.

      The problem I believe is that all the AllTheButs() parameters that Im sending to Games() and Songs() end up being ALL TRUE once they reach the function "internalmovies()". But what I want is for "holder.clip.my_btn.onRelease" in internalmovies() to load either games or songs, depending on the CatID and ClipCategory. If Cat ID==1 then, songs will be loaded. If CatID==2, then Games will be loaded. But Right now they both load games, even if we originally came from Songs().

      Does that make sense? I would be grateful for some direction.

      Thanks
      Ryan

        • 1. Re: Please Help - Functions passing parameters problem
          kglad Adobe Community Professional & MVP
          Songs() won't compile unless you correct its parameters: there should probably be a comma inserted between container and clipID.

          and where's the function call to internalmovies(), the definitions of hula_cat_song and hula_cat_game and the function call to AllTheButs() , where's image_mcl defined and finally, why are you trying to load different swfs into the same target clip at the same time?
          • 2. Re: Please Help - Functions passing parameters problem
            rring Level 1
            Let me try to explain this better.

            First there are two mistakes in my posted code that happened when I pasted them into his forum. Those mistakes are not in the FLA. They are 1. In the second conditional, it should test for "hula_cat_game", not "hula_cat_song".. the #2 mistake, is that I forgot a comma in the Games() parameters. That mistake isnt in the real code though.

            There are 2 main nav items - songs_btn and games_btn. What Im trying to do is if songs_btn is clicked, the songsmain.swf container clip loads from the hula array. That container clip, in turn, loads three button swfs into itself. Those three button swfs constitute the subnav of songs.

            I dont think attention is need to the Movie loader class here. Those are working fine.

            the issue: Each containr clip has some code that loads three subnav buttons SWFs. In the case of Songs, since we started from the songs_btn in the main nav, each of these songs subnav buttons need to have the URLS assigned to them that are found in "thesongs" array.

            So to answer, Im not trying to load the different clips into the same clip at the same time. What im trying to do, is assign the appropriate urls from the appropriate array based on conditionals. The way Ive been trying to achieve that, is by creating unique Cat IDs and having the internamovies() function check for Cat IDs to determine whether to assign urls from the "thesongs" array, or games from the "thegames" array.. But its not working.

            To answer, the internalmovies() function is called from the songsmain.swf that loads. For example, the songsmain.swf container movie has a call to _parent. internalmovies(). The function is hearing the call, but I dont know if its passing parameters correctly or not. Currently I have no parameters either container clip's call to _parent. internalmovies().

            Does that make any more sense? i could me making this much more convoluted than it needs to be

            thanks for your help!




            • 3. Re: Please Help - Functions passing parameters problem
              kglad Adobe Community Professional & MVP
              the following sentence doesn't make sense or may be causing your problem: "Currently I have no parameters either container clip's call to _parent.internalmovies()."

              all calls to internalmovies() must pass the two parameters it uses. to test use trace(Clipcat+" : "+CatIdent) in internalmovies().

              • 4. Re: Please Help - Functions passing parameters problem
                rring Level 1
                Thanks a lot for your help so far!
                So I changed it to this: _parent.internalmovies(Clipcat,CatIdent ). That didnt seem to affect anything, but I see how it its the right thing to do.

                Whats really strange now is this:

                In AllTheButs(), I have numerical CatIDs 1 & 2. internalmovies() doesnt see these Cat IDs in the conditional statements. Thus neither condition is met, and nothing plays. The trace you suggested comes back as "undedined:undefined". So it seems the parameters are not getting to interalmovies().

                Now this is vexing -- if I change the Cat IDs in AllTheButs() to something non-numerical such as "songcategoryID", then the conditional statement in interalmovies() seems to ignore trying to satisfy the CatIDs in the condition altogether, and it goes ahead and plays the clip anyway(!). The trace in this case is also "undefined:undefined". So, in sum, not only are parameters are not making it to internalmovies(), but if the CatID is non-numerical, the conditional statement is simply ignored and Flash goes ahead and plays the clip anyway. Is this a partly a datatyping issue maybe?

                I've been at this for a couple of days now. I cant figure this thing out and Im going Batty.

                Thanks again!
                Ryan


                • 5. Re: Please Help - Functions passing parameters problem
                  kglad Adobe Community Professional & MVP
                  now you know the problem: Clipcat and CatIdent. they are undefined in internalmovies() when called from songsmain.swf.

                  now go to songsmain.swf and see if the two parameters(Clipcat and CatIdent) you're using in your _parent.internalmovies(Clipcat,CatIdent ) statement are defined in songsmain. if not defined in the line just above that call to internalmovies(), why not? where is that timeline supposed to retrieve those values? if they are defined, then you have a typo in your function call. if they are not go another step back to the timeline or function where they received the values of those parameters.
                  • 6. Re: Please Help - Functions passing parameters problem
                    rring Level 1
                    Thanks for the insight! I tried declaring the Clipcat and CatIdent variables in the loading subnav buttons (where the call to interalmovies() is), and that worked.

                    However, I cant do that. I am reusing these buttons for other nav items too so they cannot have specific variables/parameters hardcoded in them. Rather, the variables/parameters must be passed from the main movie to those buttons.


                    I wish there was a way that I could just call the function internalmovies() from the songs_btn.onRelease in the main movie timeline. I dont see why I have to have a functional call in teh subnav button SWF at all. So I tried adding the internalmovies(Clipcat, CatIdent) call in the main nav songs_btn.onRelease, but the function up above doesnt receive the parametersl. I still get an ndefined:undefined . So instead, I have to pass the parameters into the loaded buttons, and then the loaded buttons have to call the internalmovie() function back in the main movie. That seems a roundabout way of doing it. But again, if I do the internalmovies(Clipcat, CatIdent) function call from the songs_btn main nav, the internalmovies() function isnt receiving the parameters in that call. Any more very very generous advice?

                    Thanks
                    Ryan

                    • 7. Re: Please Help - Functions passing parameters problem
                      kglad Adobe Community Professional & MVP
                      songs_btn should work fine (as long as you pass the correct parameters to your function Songs() ). but what's that have to do with a button in songsmain.swf?

                      is songs_btn in songsmain.swf? do you have a path reference problem?