简体   繁体   中英

AS3 I need to convert a string from input to an AS3 object

How can I do this? Here's what I have:

function send(input):void{
   // input.text = "{key: 'value'}"
   var x:* = stringToObject(input.text)

   // then be able to do this
   var y:* = x.key;

   // then y must be equal to 'value'
   trace(y) // this is just a string
}

You'll need to include the JSON library to be able to parse JSON strings into objects.

Reference the as3corelib library for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM