2 Replies Latest reply on Dec 24, 2006 9:08 AM by chris23z436

    positioning sprites dynamically

    chris23z436
      hi friends,

      i´m creating a player for movies, in director mx 2004 and on a win-pc. i would like to program it a little dynamical... here is a part of my code so far:





      global vFolder, gfolderList, gCategorysPosList


      on folderNfileList me


      vFolder = the moviePath --startupFolder
      gFolderList = baFolderList(vFolder) -- list subfolders of startupFolder
      gCategorysPosList = [[#x:100, #y:100],[#x:100, #y:200], [#x:100, #y:300]]





      repeat with vFolderName in gFolderList

      vFieldMember = new(#field) -- create new field
      vFieldMember.name = vFolderName & "member" -- give field same name as the folder has


      vString = ""
      put RETURN & vFolderName after vString
      delete char 1 of vString -- initial RETURN
      vFieldMember.text = vString -- put name of the field/folder into field

      end repeat

      repeat with vSprite = 1 to gFolderList.count

      channel(vSprite).makeScriptedSprite(member(vFieldMember), point(100, 100))
      _movie.beginRecording() -- necessary to name sprites with lingo
      sprite(vSprite).name = vFolderName -- give sprites same name as folders/categorys
      _movie.endRecording()
      end repeat

      it´s somehow wrong... :(
      what i plan to do next is positioning the separate text-fields on specific places on the stage. as you can see, i tried to save the coordinates in a list for this purpose. i intend to connect these values to the specific fields. could you please give me a hint how to? - and what´s wrong with the script i have so far? thank you in advance!





      greetings

      chris
        • 1. Re: positioning sprites dynamically
          Level 7
          Your code looks valid so far, I would avoid the score recording, if
          nothing else it complicates the development time test process, since
          saving the sile will keep the lingo score changes.

          You could setup a property list to match sprite numbers to a reference
          name


          addProp spriteXref, spriteName, spriteNum

          sprite(getProp(spriteXref, somespriteName)) -- reference stored number




          A conventional way to store locations, in place of

          gCategorysPosList = [[#x:100, #y:100],[#x:100, #y:200], [#x:100, #y:300]]

          would be

          gCategorysPosList = [point(100, 100),point(100, 200), point(100, 300)]
          • 2. Re: positioning sprites dynamically
            chris23z436 Level 1
            it works now. - thank you. oh man. lingo is soo time-consuming if you don´t do it regularly... :(
            but at least i´m able to be pleased with the little successes....

            that´s the code that worked for me, if someone else should be searching for this:



            vFolder = the moviePath --startupFolder
            gFolderList = baFolderList(vFolder) -- list subfolders of startupFolder
            gFolderPosList = [point(100, 100),point(100, 200), point(100, 300), point(100, 300), point(100, 300), point(100, 300)]



            -- erase all fields on startUp to avoid thousands of fields later.. ;)
            repeat with vEraser = 1 to (the number of members of castlib "internal")

            if member(vEraser, castlib "internal").type = #field then
            member(vEraser).erase()
            end if

            end repeat



            repeat with vFolderName in gFolderList

            vFieldMember = new(#field) -- create new field
            vFieldMember.name = vFolderName & "member" -- give field same name as the folder has


            vString = ""
            put RETURN & vFolderName after vString
            delete char 1 of vString -- initial RETURN
            vFieldMember.text = vString -- put name of the field/folder into field

            vSprite = new(#sprite) -- create new sprite (necessary for displaying on stage)
            sprite(vSprite).member = member(vFieldMember) -- fill sprites with field-members
            actPos = gFolderList.getPos(vFolderName) -- temp. shortening of that listPos-thing
            channel(actPos).makeScriptedSprite(member(vFolderName & "member"), gFolderPosList.getAt(actPos))



            end repeat