# AS3 - variable datatype from a String value?

**URL:** <https://forum.kirupa.com/t/as3-variable-datatype-from-a-string-value/201850>\
**Category:** flash\
**Created:** [September 25, 2006, 6:20pm UTC](https://forum.kirupa.com/t/as3-variable-datatype-from-a-string-value/201850 "2006-09-25T18:20:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignitrix](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ignitrix/32/2664_2.png) [@ignitrix](https://forum.kirupa.com/u/ignitrix)\
**Post date:** [September 25, 2006, 6:20pm UTC](https://forum.kirupa.com/t/as3-variable-datatype-from-a-string-value/201850/1 "2006-09-25T18:20:42Z")

</div>

Through an XMLSocket, I get a basic datatype as a String value, such as “int”, “String”, “Array”, etc… I would like to instantiate a new variable of the specified datatype. Something along the lines of the following psuedocode:

```auto

function createVariable(type:String, value:*):void
{
  var dataTypeRef:* = getDataTypeRef( type );
  var v:dataTypeRef = value;
}

```

I may be shooting for something completely impossible, but I thought I’d ask…

~JC
