1 Reply Latest reply on Jun 28, 2007 5:30 PM by ntsiii

    Creating a variable with a dynamic name

      I read a XML which has a unknown number of TextFormat-Definitions.
      I used Arrays to hold the data. Every time the TextFormat should be used, I overwrite a temporary one with the data i hold in the array and then I apply this format to the specific text.
      Now I want to optimise this and create TextFormats at once which can be applied when needed, without all the conversion.

      The best way I can think of is by having dynamic names for the TextFormats for the user to call.
      I can't use the way I did in AS2:
      var ["TF_"+string]:TextFormat = new TextFormat(x,y,z);
      How is the right Syntax in ActionScript3.0?
        • 1. Re: Creating a variable with a dynamic name
          ntsiii Level 3
          Yeah, the Application class is no longer dynamic, so you can just add members on the fly.

          You could create an "associative array" (object), and store the formats in that, keyed by 'string". Associative arrays are like hash tables and are efficient at looking up values by key.

          I have heard of but not used Dictionary objects.