2 Replies Latest reply on Apr 6, 2014 1:28 PM by Sean_Wilson

    Flash variables will not pass on enterFrame

    carl_si Level 1

      I currently have the following code setup to pass variables to a flash when a button is clicked:

       

       

      on click

           flashSprite = sprite("videoplayer")

           rootRef = flashSprite.getVariable("root1", false)

           rootRef.setUpDoc(the moviePath&"xml"&dirPath&currentMovie&"_nav.xml", the moviePath&"xml"&dirPath&currentMovie&".xml", the moviePath&"Src"&dirPath&currentMovie&".f4v")

      end

       

       

      The code works perfectly when called with "on click" but if I take this code and put it in the behavior frame and change "on click" to "on enterFrame" it give me the error:

       

       

      "Script error: Variable used before assigned a value

      rootRef.setUpDoc(the moviePath&"xml"&dirPath&currentMovie&"_nav.xml", the moviePath&"xml"&dirPath&currentMovie&".xml",

      the moviePath&"Src"&dirPath&currentMovie&".f4v")"

       

       

      Why does it work with "on click" but on with "on enterFrame"?

       

      Can anyone help me with this?

        • 1. Re: Flash variables will not pass on enterFrame
          Ladnarth Level 1

          This problem is probably related to the issue of Flash sprites not being fully instantiated on beginSprite. Delaying running your code should fix the problem. Something like the following untested code may work.

           

          on beginSprite me

            tmp = timeout().new("DelaySetupDoc", 1, #DelaySetupDoc, me)

          end beginSprite

           

           

          on DelaySetupDoc me, timeob

            flashSprite = sprite("videoplayer")

            rootRef = flashSprite.getVariable("root1", false)

            rootRef.setUpDoc(the moviePath&"xml"&dirPath&currentMovie&"_nav.xml", the moviePath&"xml"&dirPath&currentMovie&".xml", the moviePath&"Src"&dirPath&currentMovie&".f4v")

          end DelaySetupDoc

          • 2. Re: Flash variables will not pass on enterFrame
            Sean_Wilson Adobe Community Professional

            Remember to forget the timeout object, or the handler will be repeatedly called at 1ms intervals

             

            on DelaySetupDoc me, timeob

              timeob.forget()

              flashSprite = sprite("videoplayer")

              rootRef = flashSprite.getVariable("root1", false)

              rootRef.setUpDoc(the moviePath&"xml"&dirPath&currentMovie&"_nav.xml", the moviePath&"xml"&dirPath&currentMovie&".xml", the moviePath&"Src"&dirPath&currentMovie&".f4v")

            end DelaySetupDoc