2 Replies Latest reply on May 8, 2014 6:41 AM by Rod@FOF

    How to delete objects created with new

    Rod@FOF Level 1

      Hello,

       

      I am having a problem creating a behavior or script to delete new sprites created in channels. I have a behavior script that creates new sprites using the following (simplified) script:

       

      First, a Beginsprite creates a gChannel_list and assigns a beginning gChannel value. pSprite is used to establish the sprite that in the mousedown is clickon.

       

      on Beginsprite me 
        gChannel_List =[]
        gChannel = 70
        pSprite = sprite(Spritenum)
      end


      In the mousedown the gChannel is incremented and the newly created channel is added to the gChannel_list.

       

      on Mousedown me

        gChannel = gChannel + 1
        theChannel = addat(gChannel_List,gChannel)
        themember = pSprite.member

        ........

        channel(gChannel).makeScriptedSprite(themember, point(80,160))
        sprite(gChannel).width = thememberW
        sprite(gChannel).height = thememberH
        sprite(gChannel).rotation = theMemberR
        sprite(gChannel).moveablesprite = 1
        sprite(gChannel).ink = 36
        ........

      etc

       

      After creation of several sprites based on the the gChannel, the following globals, for example, are returned.

       

      -- Global Variables --
      gChannel_List = [71,72,73,74]
      gChannel = 74


      My problem is that I am unable to delete these created gchannel sprites with a lingo command. Deleting them from the list, for example, using deletat(gChannel,1), does nothing to remove them from the stage (they do disappear from the list). And while I can display their attributes such as width [n=getat(gChannel_list, x); put sprite(n).width], nothing seems to relate to deleting these gchannel sprites.

       

      How is it done?

       

      Hope this is enough information. If not, please let me know. I can provide whatever you might need. Please help.

       

      Rod