3 Replies Latest reply on Jun 7, 2006 9:17 AM by blemmo

    setInterval and attachMovie

    laura_shears
      I'm using setInterval to attach a variable number of movies. When I input the code below, the call to the function works by itself and within set interval, but the trace gives me:

      _level0.blocksHolder.randomNumberDisplay
      undefined
      undefined
      undefined

      with undefined produced the correct number of times depending on the variable: zerothPos

      The block movie clip appears once correctly when the function is called directly, but I don't want to call the function directly set I want the blocks to show up one after another instead of all at once.

      I've tried this in both MX Flash 2004 and Flash 8 with the same results. Any advice would be appreciated.

      Attached Code:
        • 1. Re: setInterval and attachMovie
          blemmo Level 1
          Hi,

          looks like a scope issue. Try the 2nd setInterval function, where you can pass the scope of the interval:
          intervalID = setInterval(this,"addUnitBlocks",1000);

          There's an issue with the attachMovie call: all attached clips will get the instance name "units", so each new clip should replace the clip attached before, resulting in only 1 clip on stage after the execution. There should be a counting var in the names, e.g.
          this.attachMovie("block","units"+blcCnt, this.getNextHighestDepth(),{_x:20*blcCnt, _y:530});

          cheers,
          blemmo

          • 2. Re: setInterval and attachMovie
            laura_shears Level 1
            Oh, thank you so much. Your suggestion worked!

            In this case having all of the clips have the same name is not a problem because I am not having the user do anything with them after they are displayed. They all get deleted at the same time anyways.

            I have used your naming scheme in many other cases when I do need the user to drag clips indepently.

            The syntax you gave me for the setInterval is what I needed. Thanks for your quick response.
            • 3. Re: setInterval and attachMovie
              blemmo Level 1
              Glad to help. I had to fight with a similar setInterval issue once, so I know it's hard to understand the scope thing if you never had this before.

              greets,
              blemmo