0
votes

I've already used Parse.com with iOS and it's great, I'm also aware of the 3rd party actionscript/parse API, but that only works with AIR.

So my question is, how would I get the parse API working with a Flash web game? (i'e with the Flash player).

There's also a PHP Parse API which uses the Parse.com REST API I believe, would that be an option? or is there just something about the Flash player that won't work with the parse API?

3

3 Answers

1
votes

There is nothing about Flash that wouldn't work with the parse rest api. If you can call the api from php you can call it from as3, c++, .net, or klingon.

0
votes

flash player cant use header unless you are POST and with sending data/variable, if you want to use parse in flash player you need a custom flash.net.URLLoader, here is the one that i have found, but for some reason it doesn't work at new version of flash player, here is the link http://www.abdulqabiz.com/blog/archives/2006/03/03/http-authentication-for-httpget-requests-using-actionscript-3/

0
votes

i found a way to perform a working REST call to Parse server

public function runParseCloudFunction(cloudFunctionName:String):void 
        {             
            if (parseRequestor != null){
                return;
            }           

            //Create the HTTP request object 
            var request:URLRequest = new URLRequest( "https://api.parse.com/1/functions/" + cloudFunctionName ); 
            request.method = URLRequestMethod.POST; 

            // Create Parse headers
            var headerAppID:URLRequestHeader = new URLRequestHeader("X-Parse-Application-Id", MY_PARSE_APP_ID);
            var headerRestKey:URLRequestHeader = new URLRequestHeader("X-Parse-REST-API-Key", MY_PARSE_REST_KEY);
            var headerContentType:URLRequestHeader = new URLRequestHeader("Content-Type", "application/json");
            request.requestHeaders.push(headerAppID);
            request.requestHeaders.push(headerRestKey);
            request.requestHeaders.push(headerContentType);

            //Add the URL variables, json encoded format (OPTIONAL)             
            request.data = '{"param1":"sample1","param2":"sample2","param3":"sample3"}';

            //Initiate the transaction 
            parseRequestor = new URLLoader(); 
            //requestor.dataFormat = URLLoaderDataFormat.TEXT;          
            parseRequestor.addEventListener( Event.COMPLETE, callParseCloudFunctionCompleted ); 
            parseRequestor.addEventListener( IOErrorEvent.IO_ERROR, callParseCloudFunctionError ); 
            parseRequestor.addEventListener( SecurityErrorEvent.SECURITY_ERROR, callParseCloudFunctionError ); 
            parseRequestor.addEventListener( HTTPStatusEvent.HTTP_STATUS, callParseStatusHandler);
            parseRequestor.load( request ); 
        }

Tested with cloud parse api version 1.3.2

Hope it helps!!