2014-07-16 4 views
0

이 텍스트 필드가 있습니다.배열을 사용하여 텍스트 필드 채우기

이름, 설명.

그리고이 어레이가 있습니다.

{"id":3157,"name":"Zhonya's Hourglass","gold":{"base":500,"total":3260,"sell":2282,"purchasable":true},"description":"<stats>+120 Ability Power<br>+50 Armor </stats><br><br><active>UNIQUE Active - Stasis:</active> Champion becomes invulnerable and untargetable for 2.5 seconds, but is unable to move, attack, cast spells, or use items during this time (90 second cooldown).","sanitizedDescription":"+120 Ability Power +50 Armor UNIQUE Active - Stasis: Champion becomes invulnerable and untargetable for 2.5 seconds, but is unable to move, attack, cast spells, or use items during this time (90 second cooldown).","colloq":"zhg;zonyas","plaintext":"Activate to become invincible but unable to take actions","depth":3,"from":["3191","1058"],"tags":["Armor","SpellDamage","Active"],"maps":{"10":false,"8":false},"image":{"full":"3157.png","sprite":"item1.png","group":"item","x":384,"y":144,"w":48,"h":48},"stats":{"FlatArmorMod":50.0,"FlatMagicDamageMod":120.0}} 

어떻게 각 필드를 name : 및 description :으로 채울 수 있으며 array [index]를 사용하지 않습니까?

나는 dataProvider를 사용하여 시도하지만 난

+0

이는 ARRAY가 아닌 JSON 객체입니다. – BadFeelingAboutThis

답변

0

뭘해야하는 것은 단지 객체 (또는 그것이 JSON있어 외부 소스에서로드 문자열 인 경우), 액세스 할 수있는 이름이나 설명을 참조하는 방법을 모른다 속성은 어떤 개체에 액세스 같은 방법 :

var data:Object = JSON.decode(YOUR_JSON_STRING); //use this line if it's a string 
var data:Object = {"id":3157,"name":"Zhonya's Hourglass","gold":{"base":500,"total":3260,"sell":2282,"purchasable":true},"description":"<stats>+120 Ability Power<br>+50 Armor </stats><br><br><active>UNIQUE Active - Stasis:</active> Champion becomes invulnerable and untargetable for 2.5 seconds, but is unable to move, attack, cast spells, or use items during this time (90 second cooldown).","sanitizedDescription":"+120 Ability Power +50 Armor UNIQUE Active - Stasis: Champion becomes invulnerable and untargetable for 2.5 seconds, but is unable to move, attack, cast spells, or use items during this time (90 second cooldown).","colloq":"zhg;zonyas","plaintext":"Activate to become invincible but unable to take actions","depth":3,"from":["3191","1058"],"tags":["Armor","SpellDamage","Active"],"maps":{"10":false,"8":false},"image":{"full":"3157.png","sprite":"item1.png","group":"item","x":384,"y":144,"w":48,"h":48},"stats":{"FlatArmorMod":50.0,"FlatMagicDamageMod":120.0}}; 

nameTextField.text = data.name; 
descriptionTextField.text = data.description 

당신은 아마 대부분의 DisplayObject의 기존 이름 속성과 충돌 할 수 있으므로, 텍스트 필드 name 이름 전화 싶지 않아요.

관련 문제