1 Reply Latest reply on Nov 20, 2007 4:37 AM by levancho

    Can't access global array

    Akshay_Gautam
      Hi,

      I am using ActionScript 2.0, and I have the following situation:

      I have a function which fetches values from database and sets those values in an array.

      Now when I am accessing those array values in another function, i am unable to access them.

      So the solution I found was to declare the array as global. I tried and searched for declaring global arrays, but no success.

      I have tried _global, at some site, i found that _global does not work in AS 2.0.
      I have also tried using variable names prefixed underscore and double underscore, but no success.

      Please suggest me a way out of this problem, how to declare global array.

      Thanks in advance.
        • 1. Can't access global array
          levancho Level 3
          there is no global per say in action script and IMHO global is a very very bad design decision, instead you can have a "global" for an instance scope, say your function that fetches array is in some class A then you can have variable in that class :

          private var myarray:Array or
          private var myClass:ArayCollection

          then if both functions are in same class you can accessing with no problem, if functions are in different class then your variable neesd a public modifier and you will also need a clas instance that holds that array in a function so that you can say

          myclassinstance.myArray