Key Value Pairs in AS3
I have a back-end PHP script sending info to an as3 app. What I have it sending is Json info, what I did to make it a key value pair was stick a key and an equals sign in front of it, and send it off. It works on smaller values, but for some reason, it's not working with this, heres the code, I hope you guys can help. Thanks :)
c3po=[{"in_reply_to_status_id":null,"favorited":false,"contributors":null,"truncated":false,"source":"API<\/a>","created_at":"Fri Jul 09 23:15:29 +0000 2010","coordinates":null,"in_reply_to_screen_name":null,"in_reply_to_user_id":null,"user":{"profile_background_image_url":"http开发者_开发问答:\/\/a1.twimg.com\/profile_background_images\/100564626\/hexagons-twtr.jpg","description":"Graphic\/web designer and blogger founder of abduzeedo","location":"Porto Alegre","profile_sidebar_fill_color":"d9f0fd","profile_image_url":"http:\/\/a3.twimg.com\/profile_images\/555183361\/avatar-hair_normal.jpg","profile_background_tile":true,"statuses_count":7520,"profile_sidebar_border_color":"c4c4c4","screen_name":"abduzeedo","lang":"en","profile_use_background_image":true,"created_at":"Mon Dec 04 23:31:20 +0000 2006","followers_count":54252,"contributors_enabled":false,"friends_count":407,"geo_enabled":true,"profile_background_color":"000000","following":false,"favourites_count":114,"protected":false,"verified":false,"profile_text_color":"525252","name":"Fabio Sasso","time_zone":"Brasilia","url":"http:\/\/www.abduzeedo.com","id":41553,"notifications":false,"utc_offset":-10800,"profile_link_color":"2d68a9"},"place":null,"geo":null,"id":18154410176,"retweeted_status":{"in_reply_to_status_id":null,"favorited":false,"contributors":null,"truncated":false,"source":"feedly<\/a>","created_at":"Fri Jul 09 22:57:03 +0000 2010","coordinates":null,"in_reply_to_screen_name":null,"in_reply_to_user_id":null,"user":{"profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/47193661\/curses_.png","description":"Degree in architecture and working with web.","location":"Porto Alegre, Brasil","profile_sidebar_fill_color":"bed3d4","profile_image_url":"http:\/\/a3.twimg.com\/profile_images\/554722981\/fabianome_normal.png","profile_background_tile":false,"statuses_count":2602,"profile_sidebar_border_color":"8cbdba","screen_name":"FabianoMe","lang":"en","profile_use_background_image":false,"created_at":"Thu Mar 27 21:07:04 +0000 2008","followers_count":1807,"contributors_enabled":false,"friends_count":191,"geo_enabled":true,"profile_background_color":"1a1107","following":true,"favourites_count":9,"protected":false,"verified":false,"profile_text_color":"25140d","name":"Fabiano Meneghetti","time_zone":"Brasilia","url":"http:\/\/fabiano.me","id":14238754,"notifications":false,"utc_offset":-10800,"profile_link_color":"d1242a"},"place":null,"geo":null,"id":18153403793,"text":"Beautiful Houses: Cliff House in Kerala, India http:\/\/bit.ly\/aAGjcb - via @GisMullr"},"text":"RT @FabianoMe: Beautiful Houses: Cliff House in Kerala, India http:\/\/bit.ly\/aAGjcb - via @GisMullr","percent":25}]
If you're using JSON, can't you just drop the key and the return only the JSON data? This is what makes more sense to me.
From your actionscript code, you could load the data setting the URLLoader dataFormat property to URLLoaderDataFormat.TEXT and parse the response data as JSON.
Otherwise, maybe rawurlencode() could help if you ghave to o with the key/values approach for some reason:
$json_data = ''; // your current data goes here
echo 'c3po=' . rawurlencode($json_data);
Are there newlines in the value? That could be a problem, depending on how you're using/reading the key values. Maybe if you post the portion of your AS3 app that's accessing the values I could provide more insight.
精彩评论