4 Replies Latest reply on Sep 4, 2011 5:40 PM by Abhilash M

    Execute or initialize code only once in lingo?

    Abhilash M

      I am doing pick and place several items like objects in director. I used a list to create points in sequence, there is a global list and counter to move to next points.

       

      How to initialize the counter =1, so that only once its executed, i'm having a problem, each time a sprite is clicked the counter takes value = 1 which i don't want.

       

      global clicklist, counter

       

      on preparemovie me

        set clicklist = [250, 180, 420, 180, 590, 180, 250, 230, 420, 230, 590, 230, 250, 280, 420, 280, 590, 280, 250, 330, 420, 330, 590, 330, 250, 380]

        counter = 1

      end

       

      Here is sequence

       

      1) Create a list for points.

      2) initalize a counter

      3) just update the counter but not make counter ==1 !

       

      after that is easy, on every sprite clicked i've a code like this,

       

      global clicklist, counter

       

      on enterframe

        -- points in a sequence order,

        -- all odd numbers represents x axis and vice versa

        set clicklist = [250, 180, 420, 180, 590, 180, 250, 230, 420, 230, 590, 230, 250, 280, 420, 280, 590, 280, 250, 330, 420, 330, 590, 330, 250, 380]

       

      end

       

      on mouseUp me

         point1 = getAt(clicklist, counter)

         point2 = getAt(clicklist, counter+1)

         sprite("mobilize").loc = point(point1, point2)

         -- shift the counter to next point of sequence

         counter = counter + 2

      end

       

      Hey guys, i'm new to adobe director, so hoping to get help.