20 Replies Latest reply on Jun 14, 2010 11:40 AM by Jhon Carlo

    member ("X"). scriptText = member ("Y"). text ... strange "behavior"

    Jhon Carlo Level 1

      I need  to have a push button which replace a script in the movie several times  to allow to play with the same button different parts of an audio file  changing "startTime" and "EndTime".
      I use the  following script:
      on mouseDown me
          
      member ("X").  scriptText = member ("Y"). text
      end
      member the "Y" replaces scriptTest to the button that  runs:
      on mouseUp me
       
      sound  (1). queue ([# member: member ("Song 1"), # startTime: 0, EndTime #:  9285])
       
      sound (1). play ()
      end
      The problem is that the first time I click the sound is not  update, although I see that the script is updated. To get the  correct sound I must click twice.
      Can someone explain why this happens?

      Thanks.

        • 1. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
          Sean_Wilson Adobe Community Professional

          Possibly because the #mouseUp message isn't being picked up because the #mouseDown was sent to a now replaced object instance. You can achieve what you want without replacing scriptText - just use a list an index property:

          property myTimeList
          property myIndex
          
          on beginSprite me
            myIndex = 1
            myTimeList = [[#start: 0, #end: 9285], [#start: 9285, #end: 18570], ... ]
          
          end
          
          on mouseUp me
            if count(myTimeList) < myIndex then
              tList = myTimeLis[myIndex]
              sound(1).queue([#member: member("Song 1"), #startTime: tList[#start], #endTime: tList[#end]])
              sound(1).play()
              myIndex = myIndex + 1
            end if
          end
          
          1 person found this helpful
          • 2. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
            Jhon Carlo Level 1

            Thank you Sean,

            I'm not to much expert of lingo, but I understand that the script you give to me is the right way.

            I need more help because in the mouse script

            I got this error message:

             

            "Script error: variable used before assigned a value

            if count(myTimeList)? < myIndex then"

             

            (I put the first six line of your script in a movie script, and the other in a mouse script)

             

            Can you give me  further help please.

            Thanks.

            • 3. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
              Sean_Wilson Adobe Community Professional

              The entire script was intended to be a behavior attached to a button. Can you explain why you saw fit to break it up into a #movie script and a #score script?

              1 person found this helpful
              • 4. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                Jhon Carlo Level 1

                Thank you again Sean,

                 

                I try to break the script because, just I've said before, I'm not to much expert of lingo, and because at first I've apply to the entire script inside a button, and now again, but it doesn't work, there is not a sound.

                 

                I want to to explain better what I need, maybe it can help:

                 

                I need to play a several number (many number) of audio file, each one with many marker, and I need to play the diferent part of the file marked with the marker. I don't want to put (by hand) each marker but I want  to take the marker position with "cuePointTimes" and play the different part with button.

                When I have finish with one file load another one, take the "cuePointTimes", and so on ...

                 

                I hope Sean you can show me the way

                 

                Thank you again.

                • 5. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                  Sean_Wilson Adobe Community Professional

                  If you would explain your requirements at the outset it might lead to a solution faster.

                   

                  So you have a button that "loads" a new sound? How is this done?

                   

                  And you have a single button that plays each 'section' in order, or many buttons that allow the end-user to randomly choose a section to play?

                  • 6. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                    Jhon Carlo Level 1

                    Thank for your fast and kind reply,

                     

                    1) I need to load the sound from menu;

                     

                    2) I need a single button that play each session in order.

                     

                    Thank you very much

                    • 7. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                      Jhon Carlo Level 1

                      Sorry Sean,

                      the number two of my previous reply is incorect, this is correct:

                       

                      2) I have several button (1, 2,  3, 4 and so on) the first button play the first part, the second button the second part and so on ...

                      • 8. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                        Jhon Carlo Level 1

                        I try to arrange the script in this way, it works (I hear the sound and playeach section):

                         

                         

                         

                        property myTimeList
                        property myIndex

                         

                        on beginSprite me
                          myIndex = 1
                          myTimeList = [[#start: 0, #end: 9285], [#start: 9285, #end: 18570] ...]
                        end

                         

                        on mouseUp me
                          -- if count(myTimeList) < myIndex then
                          tList = myTimeList[myIndex]
                          sound(1).queue([#member: member("Sound x"), #startTime: tList[#start], #endTime: tList[#end]])
                          sound(1).play()
                          myIndex = myIndex  + 1
                          -- end if
                        end

                         

                        My next problem is:

                        How insert the quepoint in the timeList

                         

                        Thank you.

                        • 9. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                          Sean_Wilson Adobe Community Professional

                          The easiest way to generate your start/end time list is by using Lingo to do it for you when a sound file is "loaded". I have no idea how you load a sound file (are they all already in your cast library, or do you import then dynamically at run time). Post some code that show how you load a new sound and I'll help you with code to create the start/end list, but in general terms I would have your load script notify the previous behavior script that a new sound has been loaded and this behavior would parse the cuePointTime list of this sound file building the start/end times as it goes. Does that make sense?

                          • 10. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                            Jhon Carlo Level 1

                            Thank you for  your constant kindness.

                             

                            1) Audio casts are all  already in the cast library.
                            2) With your help I  changed the script (Icut the if condition) and I play the sound with a single button, the script is:

                             

                            property myTimeList
                            MyIndex property

                            beginSprite on  me
                             
                            MyIndex = 1
                             
                            myTimeList  = [[# start: 0, # end: 9285], [# start: 9285, # end: 18570], [# start:  18570, # end: 199000]]
                            end

                            on mouseUp me
                             
                            - If count  (myTimeList) <MyIndex then
                             
                            tlist =  myTimeList [MyIndex]
                             
                            sound (1). queue ([#  member: member (sound1), # startTime: tlist [start #] # EndTime: tlist  [# end]])
                             
                            sound (1). play ()
                             
                            MyIndex MyIndex + 1 =
                             
                            - End if
                            end

                            The button that  plays in the sequence 1,2,3 ... part of the audio file, but if you had the  time to show me a solution where the button 1 plays the part 1 and the button 2 play the part 2 etc. would be better.

                            So now I need a script that read and write (into MyTimeList) the cue point of an any audio catst member.

                            Because of my bad English I do not understand the last part of  your answer.
                            I hope I've given you enough  information.
                            I await your reply with  impatience.
                            Thanks Sean.

                            • 11. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                              Sean_Wilson Adobe Community Professional

                              I asked you to supply the code that "loads" a new sound and you have chosen to ignore my request and claim your impatience. I appreciate that English isn't your first language but if you didn't understand my request you might have asked for clarification.

                               

                              Since I now - through this back-and-forth process have a better understanding of your requirements I will approach this differently. I suggest that you list of times is a global variable that is set/updated when a sound is loaded. This simplifies the button scripts to play sections down to:

                              global gTimeList
                              global gLoadedSound
                              
                              property myIndex
                              
                              
                              on getPropertyDescriptionList
                                return [#myIndex: [#comment: "Play section number:", #format: #integer, #default: 1]]
                              end
                              
                              
                              on mouseUp me
                                if MyIndex <= count(gTimeList) then
                                  tlist =  myTimeList [MyIndex]
                                  sound(1).queue([#member: gLoadedSound, #startTime: tList[#start], #EndTime: tList[#end]])
                                  sound(1).play()
                                end if
                              end
                              

                              When you attach this behavior to all of your buttons you will be able to choose which section of the sound they will each play. That is: you only need this one behavior for all of your play buttons.

                               

                              When a new sound is loaded you need to set up the 2 global variables: gTimeList and gLoadedSound

                              -- #movie script:
                              global gTimeList 
                              global gLoadedSound
                              
                              on YourHandlerName
                                -- code to "load" a new sound here
                              
                                -- I don't know how you determine which member is loaded:
                                gLoadedSound = member("audio cast member name")
                                mGenerateTimeList()
                              end
                              
                              on mGenerateTimeList
                                gTimeList = []
                                tStart = 0
                                repeat with aTime in gLoadedSound.cuePointTimes
                                  gTimeList.append( [#start: tStart, #end: aTime] )
                                  tStart = aTime
                                end repeat
                              end
                              
                              • 12. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                Jhon Carlo Level 1

                                 

                                 

                                 

                                Thank you very much for you kind reply.

                                I'm sorry not having asked for clarification for the last part of your previous message, of course I ask you about this if it is necessary. With my short reply I mean that you may consider it if it was enough.

                                I tell you before that I was waiting for your reply with impatience  only to mean how important was your reply for me and give you some right thanks. If there is any misunderstanding of course it is my fault.

                                While I tell you my last test:

                                 

                                1) I have make the movie script and I have put, by hand, in the line 9, the name of sound:

                                "gLoadedSound = member("Sound x")" .

                                (Sound x is in the cast member).

                                 

                                2) I have put in diferent button the script that you give me in the last message.

                                 

                                When I run the movie I get this error message:

                                 

                                "Script error: variable used before assigned a value

                                tlist = myTimeList [? myIndex]"

                                About how to load the sound, I'd like to do this from menu' but  I have not script now because your better new script change the situation.

                                I do it before  with some complex operation. From the menu I insert a behaviour that do this things:

                                 

                                1) copy the cue point inside a text "text cue point";

                                 

                                2) copy (for exemple) the word 1 (the first word of "text cue point" (the cue point 0) inside another text, word 3 (the #startTime) (look below).  Copy the second word (of "text cue point" (the cue point 9285) inside the word 5 of the text below (the #endTime) and so on …

                                 

                                sound(1).queue([#member:member("PinkFloydDarkSide1"), #startTime: 0 , #endTime: 9285 ] )

                                 

                                3) Copy the line above of the text, inside the script text of the button that play the sound. But (this is the first  reason of this discussion) the first time I click the sound is not  update.

                                Your way is more elegant, and I'd like to finish the script in your way.   

                                 

                                Remember  I'm "Impatient" .

                                • 13. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                  Sean_Wilson Adobe Community Professional
                                  2) I have put in diferent button the script that you give me in the last message.

                                   

                                  When I run the movie I get this error message:

                                   

                                  "Script error: variable used before assigned a value

                                  tlist = myTimeList [? myIndex]"

                                  My code should have been:

                                  global gTimeList
                                  global gLoadedSound

                                  property myIndex


                                  on getPropertyDescriptionList
                                    return [#myIndex: [#comment: "Play section number:", #format: #integer, #default: 1]]
                                  end


                                  on mouseUp me
                                    if MyIndex <= count(gTimeList) then
                                      tlist =  gTimeList[MyIndex]
                                      sound(1).queue([#member: gLoadedSound, #startTime: tList[#start], #EndTime: tList[#end]])
                                      sound(1).play()
                                    end if
                                  end

                                   

                                   

                                  I don't know what to do about your point (1) since it's completely unclear how your user chooses between different sound files and you haven't provided enough clues.

                                  • 14. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                    Jhon Carlo Level 1

                                    Thanks Thanks Thanks. You are great Sean!!!

                                    Now when iI drag the script into a button I get: "Play section number ...."

                                    (In the previous tests I got only the error message that you know).

                                    Please be patient with me Sean I need (I hope for you) the last help.

                                    Now It is all ok. I can have diferent button the play diferent section.

                                    The movie script is:

                                    Immagine.jpg

                                     

                                     

                                    But I have write the code with my keyboard. I don't know the lingo code for:

                                    1) change the line 7/8

                                    2) change the name of the member in line 10.

                                     

                                    For my current  knowledge the only thing that I can imagine Is write the code with keyboard inside a text and exchange it (changing only the lines that change) with the script text of the movie script.

                                    So I need some other code (for the above lines 7/8 and 10) to chooses between different sound file.

                                    I want to select diferent sound file in this way:

                                    1) going inside the menu and:

                                    2) select: sound file 1, or sound file 2, or sound file 3 and so on....

                                     

                                    Now I'm more "inpatient" that ever in my life (a little bit a joke a little bit true,I don't know the different and exact shades of meaning of the word "Impatient" in English), but you take all your time. Ask to me all you need for your help.

                                     

                                    Thank again.

                                    • 15. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                      Sean_Wilson Adobe Community Professional

                                      I'm going to assume that you don't have a mechanism for selecting sound files already in place, so I will (hopefully) create one for you that works. You keep referring to a 'menu' so I'll assume you really do want a menu you can select sound files from. The following is a #movie script and should replace/supercede the previous movie script I posted (post number 11). The following requires NO changes to the (corrected) button script (post number 13):

                                      -- #movie script:
                                      global gTimeList 
                                      global gLoadedSound
                                      
                                      on prepareMovie
                                        mInstallSoundMenu()
                                      end
                                      
                                      on mInstallSoundMenu
                                        -- start by creating a list of sound member names:
                                        lSoundMemberNames = []
                                        nLibs = _movie.castLib.count
                                        repeat with ll = 1 to nLibs
                                          nMembers = castLib(ll).member.count
                                          repeat with mm = 1 to nMembers
                                            if member(mm, ll).type = #sound then lSoundMemberNames.append(member(mm, ll).name)
                                          end repeat
                                        end repeat
                                        
                                        -- construct menu text for a field to use with 'installMenu'
                                        tMenuText = "menu: Sounds" &RETURN
                                        repeat with aSoundMemberName in lSoundMemberNames
                                          put aSoundMemberName & "|" & "mLoadSound(" &QUOTE& aSoundMemberName &QUOTE& ")" &RETURN after tMenuText
                                        end repeat
                                        delete the last char of tMenuText
                                        
                                        -- does the field member exist?
                                        tMenuField = member("menu field")
                                        if ilk(tMenuField, #member) = 0 then
                                          tMenuField = _movie.newMember("field")
                                          tMenuField.name = "menu field"
                                        end if
                                        tMenuField.text = tMenuText
                                        
                                        installMenu tMenuField
                                      end
                                      
                                      on mLoadSound aSoundName
                                        gLoadedSound = member(aSoundName)
                                        mGenerateTimeList()
                                      end
                                      
                                      on mGenerateTimeList
                                        gTimeList = []
                                        tStart = 0
                                        repeat with aTime in gLoadedSound.cuePointTimes
                                          gTimeList.append( [#start: tStart, #end: aTime] )
                                          tStart = aTime
                                        end repeat
                                      end
                                      
                                      • 16. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                        Jhon Carlo Level 1

                                        Many thanks Sean.

                                         

                                        You can not imagine my joy when I see in my post "Sean_Wilson".

                                         

                                        Now everything works !!!!!!!!!!!

                                         

                                        I understand of the distance that separates a professional dimension from  a beginners.

                                         

                                        I am a professional in another field that (as you can well imagine) is not 'lingo.

                                         

                                        However for me it is fantastic the way you have solved my problem, and I am amazed.  

                                         

                                        With reference to the script, I try to modify it a bit because I want to insert the "sound" menu inside of a menu that I alredy have,  together with others menu list, and I need do not use all the sound of my movie but only a few. But I will not bother you further.

                                         

                                        The ten points for "correct answer" are few, I'd give you at least 1000.

                                         

                                        Sorry for my bad english, thank you for your patience and  Many Many Many thanks Sean.

                                         

                                         

                                         

                                        • 17. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                          Sean_Wilson Adobe Community Professional
                                          With reference to the script, I try to modify it a bit because I want to insert the "sound" menu inside of a menu that I alredy have,  together with others menu list, and I need do not use all the sound of my movie but only a few.

                                          1). You will need to provide the menus you already have (or the fields their definition is already stored in) along with where you would like sound selection to be included.

                                          2). You will need to show how the sounds you do want included are distinguished from any others.

                                          • 18. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                            Jhon Carlo Level 1

                                            Point 1)  is no longer a problem;
                                            For point 2) I want to include sounds that  are all in a library named "sound".
                                            I'm trying to  find a way to distinguish them from others. For the moment,  no positive result.

                                             

                                            • 19. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                              Sean_Wilson Adobe Community Professional
                                              For point 2) I want to include sounds that  are all in a library named "sound".

                                               

                                                -- start by creating a list of sound member names:
                                                lSoundMemberNames = []
                                                -- nLibs = _movie.castLib.count
                                                -- repeat with ll = 1 to nLibs
                                                nMembers = castLib("sound").member.count
                                                repeat with mm = 1 to nMembers
                                                  if member(mm, "sound").type = #sound then lSoundMemberNames.append(member(mm, "sound").name)
                                                end repeat
                                                -- end repeat
                                              • 20. Re: member ("X"). scriptText = member ("Y"). text ... strange "behavior"
                                                Jhon Carlo Level 1

                                                Thanks Sean.
                                                Now all is realy realy  perfectly
                                                I'm without word, I'm astonish, glad and gratefull
                                                Cause of your help today for me is a better day.
                                                Thanks Sean.