7 Replies Latest reply on Jan 29, 2008 8:02 AM by Newsgroup_User

    script timing

    Level 7
      I have made a small custom tickbox, of which I place seceral instances on
      the screen.

      I also have a function that runs and makes calculations based on the status
      of these tickboxes.

      My problem is that the function runs before the tickboxes have been drawn,
      so I cannot access the values at the time the function runs.

      I assume that flash always processes the script, then draws ant graphics? Is
      that correct?

      How can I get around this?

      Many thanks


        • 1. Re: script timing
          kglad Adobe Community Professional & MVP
          object placed on-stage in the authoring environment in a given frame are available to actionscript when the playhead enters that frame.

          code in a function is executed when that function is called. you should be able to time your function call to suit your needs.
          • 2. Re: script timing
            Level 7
            Thanks for the reply, but it really doesn't seem to be working that way. I
            have a frame with 15 tickboxes, named tb1 to tb15 (each tick box is a 2
            frame movie clip, which set it's own variable to 0 or 1 depending on whether
            it is ticked or not)

            I then have a function on the main timeline with this code

            function TEMP_FUNC(){
            trace("my checkbox1="+tb1.vSELECTED);
            }
            TEMP_FUNC();

            The trace is "my checkbox1=undefined"

            when the playhead enters that frame.

            I really don't understand it!




            "kglad" <webforumsuser@macromedia.com> wrote in message
            news:fnkpp5$575$1@forums.macromedia.com...
            > object placed on-stage in the authoring environment in a given frame are
            > available to actionscript when the playhead enters that frame.
            >
            > code in a function is executed when that function is called. you should
            > be
            > able to time your function call to suit your needs.
            >


            • 3. Re: script timing
              kglad Adobe Community Professional & MVP
              recheck the instance names of your checkboxes (case counts) and recheck the name of the variable assigned to tb1 (and again, case counts).

              if tb1 is on-stage in the frame that contains your TEMP_FUNC() call and it has a vSELECTED properity that's been assigned, you will not see undefined in your output panel.
              • 4. Re: script timing
                Level 7
                I've looked at this for over an hour now, and it's driving me nuts!!

                The tick box is a movie clip with two frames. Frame 1 sets the vSELECTED to
                1 (ticked state) and frame 2 sets vSELECTED to 0 (unticked).

                When I arrive at the frame that contains the movieclip tb1 the value of
                tb1.vSELECTED is undefined

                If I then click on the movie clip, which moves it to the next frame then I
                get a value for vSELECTED.


                "kglad" <webforumsuser@macromedia.com> wrote in message
                news:fnkrl6$790$1@forums.macromedia.com...
                > recheck the instance names of your checkboxes (case counts) and recheck
                > the
                > name of the variable assigned to tb1 (and again, case counts).
                >
                > if tb1 is on-stage in the frame that contains your TEMP_FUNC() call and it
                > has
                > a vSELECTED properity that's been assigned, you will not see undefined in
                > your
                > output panel.
                >


                • 5. Re: script timing
                  kglad Adobe Community Professional & MVP
                  code on a movieclip's timeline executes after code that's in the timeline that contains the movieclip.

                  having code scattered across multiple timelines is poor coding practice. but if you want to continue doing that you just need to delay execution of your function for 1 ms. using setTimeout or setInterval() works.
                  • 6. Re: script timing
                    Level 7
                    Thanks for this, I'll try to keep all code on the main timeline, although I
                    sort of thought that was one of flash's strengths, that you could have
                    independent chunks of code running in different movieclips. Or is that not
                    really the case?

                    "kglad" <webforumsuser@macromedia.com> wrote in message
                    news:fnl924$m3h$1@forums.macromedia.com...
                    > code on a movieclip's timeline executes after code that's in the timeline
                    > that
                    > contains the movieclip.
                    >
                    > having code scattered across multiple timelines is poor coding practice.
                    > but
                    > if you want to continue doing that you just need to delay execution of
                    > your
                    > function for 1 ms. using setTimeout or setInterval() works.
                    >


                    • 7. Re: script timing
                      Level 7
                      Well, you can have different chunks of code executing for different movie
                      clips. However, that code shouldn't be placed inside the clips... you want
                      to keep your code organized, and easy to find, so it should all be in one
                      place - usually frame 1 of root. If you have a movieClip containing a button
                      and you want to put a release handler on that button, you don't go into the
                      clip and add code, you target the button from the main timeline:

                      someClip.someButton.onRelease = function(){
                      trace("clicked");
                      }



                      --
                      Dave -
                      Head Developer
                      http://www.blurredistinction.com
                      Adobe Community Expert
                      http://www.adobe.com/communities/experts/