# There has to be a better way... to call Constants in AS3

**URL:** <https://forum.kirupa.com/t/there-has-to-be-a-better-way-to-call-constants-in-as3/326783>\
**Category:** flash\
**Created:** [January 12, 2012, 12:36am UTC](https://forum.kirupa.com/t/there-has-to-be-a-better-way-to-call-constants-in-as3/326783 "2012-01-12T00:36:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaChillWizard](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@DaChillWizard](https://forum.kirupa.com/u/DaChillWizard)\
**Post date:** [January 12, 2012, 12:36am UTC](https://forum.kirupa.com/t/there-has-to-be-a-better-way-to-call-constants-in-as3/326783/1 "2012-01-12T00:36:54Z")

</div>

Hello and thanks in advance if anyone can come up with a better way to handle this in AS3.

Basically I want to call a const by a int.

here is the code i have so far…

public static const \_100:String = “name=lion legs_type=legs";  
public static const \_101:String = "name=lion tail_type=tail”;  
public static const \_200:String = “name=tiger legs\*type=legs”;

///more lines going down with the number on the far left being the main differentiating factor

public static function getByName(name:int):String {  
switch(name) {  
case 100 :  
return \_100;  
break;

```
     case 101 :
          return _101;
      break;

     case 200:
          return _200;
     break;

```

…///i dont want to write a case for every const X[

```
      default : return _0;
 }

```

}

is there a better way out there to call the constants by an outside int without having a switch function handle the logic? Thanks again :] :samus\_v2:
