6 Replies Latest reply on Jul 30, 2009 3:23 AM by NewFlasherFromKS

    How to create a "package wide" variable?

    NewFlasherFromKS

      Hello out there,

      I am a seasoned programmer with a strong C/C++ background, but how to design in AS (using FlexBuilder 3) is still somewhat of a mystery to me.

      I think I grok the basics of the package mechanism by now, but apparently something is missing: I am creating (visual) objects at runtime and need to keep track of them, so that I can remove them when needed.

       

      I read somewhere that you could have a variable which can be shared among all classes of a package. So I tried

      package components {

               import flash.display.Sprite;

         internal var thingies:Array = new Array();     // this should become my 'shared' variable

       

         public class DrawGrid extends Sprite {}

      }

      and get the message

           A file found in a source-path can not have more than one externally visible definition.

      after I added my 'thingies' variable.

      'externally visible' ? when marked as 'internal'?

       

      There must be a way - I am sure that I am just having a blind spot.

      Any "eye-opening" help will be greatly appreciated.

      Best regards

      Helmut