13 Replies Latest reply on Jul 19, 2010 10:28 AM by efeelo

    Castmembers counting and display one by one on the stage

    efeelo

      I created a code to build lists of casts embers for display on the stage one by one and want to be able to use mouse click to move from cast member to cast member back and fort but I have difficulty getting this right. I have

      gotten index out of range error mostly. I had move the counter to various position but did not get it right.

      Does anyone have a suggestion?

        • 1. Re: Castmembers counting and display one by one on the stage
          efeelo Level 1

          Castmember counting and displaying.jpg

           

          This is the code I have custom written to do this, it list the first cast member and jumps to the last at some point with index out of range error.

          • 2. Re: Castmembers counting and display one by one on the stage
            Sean_Wilson Adobe Community Professional

            Please copy and paste your code into the editor here, not as a screenshot.


            • 3. Re: Castmembers counting and display one by one on the stage
              efeelo Level 1

              Hello Sean_Wilson

               

              Here is my custom codes:

               

               

              Global thewordnumber

               

              Global thewordcounter

               

              Global theword

               

              Global wordlist

               

              Global soundList

               

              Global wordCounter

               

              global thedefnumber

               

              global thedefcounter

               

              global defList

               

              global thedef

               

              global thepronunnumber

               

              global thepronuncounter

               

              global pronunList

               

              global thepronun

               

              global thecontextnumber

               

              global thecontextcounter

               

              global contextList

               

              global thecontext

               

               

               

               

               

              On BuildList

               

               

               

                thewordcounter = 1

               

                wordList = []

               

                soundList = []

               

                thedefcounter = 1

               

                defList = []

               

                thepronuncounter = 1

               

                pronunList = []

               

                thecontextcounter = 1

               

                contextList = []

               

               

               

                c = 250

               

                i = 1

               

                p = ""

               

                s = ""

               

                repeat while i <= c

               

                  if i < 10 then

               

                    p = "00" & i

               

                  else if i < 100 then

               

                    p = "0" & i

               

                  else

               

                    p = i

               

                  end if

               

                  add wordList, "word - " & p

               

                  add defList, "def - " & p

               

                  add pronunList, "pronun - " & p

               

                  add contextList, "context - " & p

               

                  add soundList, i

               

                  i = i + 1

               

                end repeat

               

                return wordList

               

                return defList

               

                return pronunList

               

                return contextList

               

                c = c + 1

               

              end

               

               

               

               

               

              On Mousedown me

               

                Buildlist

               

               

               

                wordCounter = 250

               

                thewordcounter = 1

               

               

               

                repeat while thewordcounter <= wordCounter

               

                  if thewordcounter < 251 then

               

                    thewordcounter = thewordcounter + 1

               

                    wordCounter = thewordcounter

               

                    thewordnumber = wordList[wordCounter]

               

                    theword = member(thewordnumber)

               

               

               

                    defCounter = thedefcounter

               

                    thedefnumber = defList[defCounter]

               

                    thedef = member(thedefnumber)

               

               

               

                    pronunCounter = thepronuncounter

               

                    thepronunnumber = pronunList[pronunCounter]

               

                    thepronun = member(thepronunnumber)

               

               

               

                    contextCounter = thecontextcounter

               

                    thecontextnumber = contextList[contextCounter]

               

                    thecontext = member(thecontextnumber)

               

               

               

                    set the member of sprite (2) = theword

               

                    set the member of sprite (3) = thepronun

               

                    set the member of sprite (4) = thedef

               

                    set the member of sprite (5) = thecontext

               

                    set the member of sprite (9) = thewordcounter

               

               

               

                  else

               

                    Alert "I am not doing what you want me to do"

               

                  end if

               

               

               

                end repeat

               

                return wordList

               

                return defList

               

                return pronunList

               

                return contextList

               

               

               

                wordCounter = wordCounter + 1

               

               

               

              end

               

               

               

               

               

              Thank you

              • 4. Re: Castmembers counting and display one by one on the stage
                Sean_Wilson Adobe Community Professional

                While lists are a powerful and useful tool, I think you can get by without them in your case.

                 

                Try the following behavior attached to your button:

                global gCurrentCounter
                
                on beginSprite me
                  gCurrentCounter = 1
                end
                
                on mouseUp me
                  if gCurrentCounter < 10 then
                    p = "00" & gCurrentCounter
                  else if gCurrentCounter < 100 then
                    p = "0" & gCurrentCounter
                  else
                    p = gCurrentCounter
                  end if
                  sprite(2).member = member("word - " & p)
                  sprite(3).member = member("def - " & p)
                  sprite(4).member = member("pronun - " & p)
                  sprite(5).member = member("context - " & p)
                  sprite(9).member.text = gCurrentCounter -- ??
                  
                  if ( gCurrentCounter < 250 ) then gCurrentCounter = gCurrentCounter + 1
                end
                
                • 5. Re: Castmembers counting and display one by one on the stage
                  efeelo Level 1

                  Hello Saen_Wilson

                   

                  Thank you for the suggested code, please tell me this:

                   

                  why the question marks here?

                   

                  sprite(9).member.text = gCurrentCounter -- ??

                   

                  If the counters become cast members, I can list and hopefully list them with

                  same statement such as this below?

                  sprite(9).member = member("counter - " & p).

                   

                  Is there a better and simple formatted code for this?

                   

                  Thanks.

                   

                  efeelo.

                  • 6. Re: Castmembers counting and display one by one on the stage
                    Sean_Wilson Adobe Community Professional

                    The question marks were because I couldn't tell what you were trying to do. If there are cast members named like you suggest ("counter - " & p) then your code should work - try it and see.

                    • 7. Re: Castmembers counting and display one by one on the stage
                      efeelo Level 1

                      Hello Sean_Wilson

                       

                      I used List and return functions because they bring all the associated

                      charisteistics listed in the fields together. With the counter, the sound

                      does not work. There are sounds associated with each field that I would like

                      to make sure they play.

                       

                      So, just counting and moving through the casts does not  fulfil what I want

                      to do.

                       

                      I hope you can help.

                       

                      efeelo.

                      • 8. Re: Castmembers counting and display one by one on the stage
                        Sean_Wilson Adobe Community Professional

                        I saw your sound list declared and filled, but nowhere was there code dealing with playing it, so I figured the list was a left-over from a previous attempt that had been abandoned. What's more, your sound list is filled with integers - I have no way of knowing how you were going to use these to play sounds.

                        • 9. Re: Castmembers counting and display one by one on the stage
                          efeelo Level 1

                          There are buttons attached to the fronts of the fields with code such as

                          this:

                           

                          On MouseDown me

                           

                          Global soundList

                           

                          Global wordCounter

                           

                           

                          sprt_sound=soundList[wordCounter]&"a"

                           

                          Puppetsound 1, sprt_sound

                           

                          end

                          • 10. Re: Castmembers counting and display one by one on the stage
                            Sean_Wilson Adobe Community Professional

                            So what about something like:

                            global gCurrentCounter
                            
                            on mouseUp me
                              sSoundName = gCurrentCounter & "a"
                              sound(1).play(member(sSoundName))
                            end
                            
                            • 11. Re: Castmembers counting and display one by one on the stage
                              efeelo Level 1

                              Hello Sean_Wilson

                               

                              This does not work exactly the way it should since logically, the mouseup

                              handler is mostly what this react to. The logics really needs to be more

                              grounded than what we have so far in order for this to work properly.

                               

                              Trying to to count forward and back, the logic is messing up.

                               

                              Thanks.

                               

                              efeelo.

                              • 12. Re: Castmembers counting and display one by one on the stage
                                efeelo Level 1

                                Your sugestions have been greatly motivating and very helpful. I have done,

                                thanks a lot.

                                • 13. Re: Castmembers counting and display one by one on the stage
                                  efeelo Level 1

                                  Hey Sean_Wilson, I mean we have done it. It is working very well, I figured

                                  out the sequence that will do exactly what I want it to do.

                                   

                                  Thank you again.

                                   

                                  efeelo.