0
votes

does anyone know if you can use the Flex HTTPService library with Flash IDE in AS3?

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/http/HTTPService.html

or if there is a similar library to use that does the same thing?

basically i am connecting to a HTTPS address and posting some headers to again access to a REST service, this all works perfectly fine through the Flash IDE/Player.

soon as i export the exact same code to AIR for Desktop i get a 405 error (apparently there is no sandbox violation for AIR for Desktop i have tried this for other URLs it works but does not for this HTTPS address).

apparently making the exact same call to the REST/HTTPS address but using the Flex HTTPService works? anyone know why this is or know any work around for this?

1

1 Answers

1
votes

ok so i managed to find a work around hope this helps someone else.

i used the flex HTTPService mentioned above the way i got it to work is by including the flex SWC's into the Actionscript 3.0 settings library path; "rpc.swc" & "framework.swc".

here's some of the code and imports using.

import mx.rpc.events.*;
import mx.rpc.http.*;

var httpService : HTTPService = new HTTPService();
httpService.method = HTTPRequestMessage.GET_METHOD;

httpService.headers["Username"] = "user";
httpService.headers["Password"] = "pass";

httpService.url = "https://...../";
httpService.resultFormat = "e4x";
httpService.addEventListener( ResultEvent.RESULT, resultFunction );
httpService.addEventListener( FaultEvent.FAULT, faultFunction );
httpService.send();

function resultFunction(result: ResultEvent):void{
    //String(result.result);
}

function faultFunction(event: FaultEvent) : void{
    //String(event.fault);
}