0

I have a program(as 3.0 .swf) that takes a users name, email and the desired information they want to receive. It then creates an email and passes these variables to my server where a php file sends it to the email the user entered. When I test the program in flash it works great. The email goes right through. But when I export it the program is unable to connect. I have the setting to "access network only." I have published an AIR and html version as well and neither work. I have spent 2 and a half hours searching and have found people with the same problem but no answers. This is the only thing stopping me from launching the program!

Heres my code:

import flash.events.Event;

//---------------Setup variables
var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("http://myserver/phpfile.php");


var variables:URLVariables = new URLVariables();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
req.method = URLRequestMethod.POST;
var Info:String = "";
//tab index
txName.tabIndex = 0;
txEmail.tabIndex = 1;
//listener fot textfield changes
txName.addEventListener(Event.CHANGE, txErrorCheck);
txEmail.addEventListener(Event.CHANGE, txErrorCheck);
function txErrorCheck(event:Event):void {
if (txError.text.length>0) {
    txError.text = "";
}
}
SEND.addEventListener(MouseEvent.CLICK, sendForm);
function sendForm(evt:MouseEvent):void {
if (txName.text.length<=0) {
    txError.text = "Please Enter A Name";
} else if (!txEmail.text.length || txEmail.text.indexOf("@") == -1 ||        txEmail.text.indexOf(".") == -1) {
    txError.text = "Please Enter A Valid Email!";
} else {
    mcLoader.gotoAndPlay(2);
    variables.senderName = txName.text;
    variables.senderEmail = txEmail.text;
    variables.Info = Info;
    req.data = variables;
    loader.load(req);
    loader.addEventListener(Event.COMPLETE, receiveLoad);
}
}
function receiveLoad(evt:Event):void {
if (evt.target.data.retval == 1) {
    mcLoader.gotoAndStop(25);
} else {
    mcLoader.gotoAndStop(1);
    txError.text="**  SERVER ERROR **";
}
}
//Reset form
function resetForm(evt:MouseEvent):void {
txName.text="";
txEmail.text="";
}
stop();
Dairo
  • 822
  • 1
  • 9
  • 22

1 Answers1

1

Have a look at adobe flash security polocies. You should have a cross-domain xml file in the root of your server. In debug mode it always works because security is skipped.

Take a look at this post AS3 | SWF load issue or google about using cross-domain.xml files inside flash.

Community
  • 1
  • 1
Adrian Pirvulescu
  • 4,308
  • 3
  • 30
  • 47
  • Thanks!!! I was about ready to throw my computer out the window as I have been trying to figure this one out for almost 2 weeks now with nothing. – user3381715 Mar 05 '14 at 20:01
  • ohh.. please don;t do that. Alsways put an alert.show(error) when you are in the test phase on your error hadling... you never know what can do wrong in a released version... – Adrian Pirvulescu Mar 06 '14 at 08:11