0

I'm having a problem with passing my JSON (Converted to Array) data from PHP to ActionScript 3.0 .

Here is my php code:

class myTwitterOAuth {

    public function get_user($username) {

        $oauth = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret);
        $param = array('screen_name'=>'twitter');
        $data = $oauth->get('users/show', $param);
        $json = json_encode($data);
        $JSONarray=json_decode($json, true);
        return $JSONarray; //To pass the whole Array not working
    }
}

Now for my Action Script Method:

function whenSuccess(res:Object):void{  
    trace(res['name']); //Not working at all Neither name nor screen_name or any
}

Error I'm getting from Adobe Flash:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at AS3PHPTesting01_fla::MainTimeline/whenSuccess()

UPDATE

I'm using Amfphp library to communicate between PHP and Action Script. Here is how I'm doing it:

var gateway:String = "http://website/here/Amfphp/index.php";
var connection:NetConnection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, errorConnection);
var res:Responder = new Responder(whenSuccess, whenFail);

connection.connect(gateway);
connection.call('myTwitterOAuth/get_user', res, param);
1
  • How do you call the PHP from your ActionScript? In your exemple, it is obvious that res is null, but it is impossible to know why unless we see the relevant code. Commented Jun 17, 2013 at 13:17

2 Answers 2

1

Tip: Try first to receive your results from the AMFPHP browser. When you receive your data correctly from the webservice in the browser you'll be able to use it in AS3.0.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you elaborate more if possible? Thanks!
He's saying test it in the AMFPHP browser first..not really sure of another way of saying that lol
0

Try this inside the function whenSuccess to check what you are really receiving

for (var prop in res){
    trace(prop, res[prop]);
}

1 Comment

This is what I'm getting Cannot access a property or method of a null object reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.