Haven't tried this with the 1.38 version, but in the 2.x version the following works just fine:
ActionScript 3.0 part (the swf with the form loaded into the book):
stop();
// request related vars and setup
import de.mightypirates.megazine.interfaces.IMegaZine;
// initialize request var with path relative to megazine.swf
function megazineSetup(megazine:IMegaZine):void {
variableSend =
new URLRequest(megazine.getAbsPath
("form_eval.php"));
variableSend.data = variables;
}
// perform the request
function sendFormData():void {
variables.username = txtName.text;
variables.email = txtMail.text;
variableLoader.load(variableSend);
}
// build form
graphics.beginFill(0, 0.5);
graphics.drawRect(0, 0, 100, 75);
graphics.endFill();
txtName.width = 100;
txtName.height = 25;
txtName.background = true;
txtName.border = true;
addChild(txtName);
txtMail.width = 100;
txtMail.height = 25;
txtMail.background = true;
txtMail.border = true;
txtMail.y = 25;
addChild(txtMail);
btnSend.y = 50;
addChild(btnSend);
// build button states...
switch (type) {
case 0:
s.graphics.beginFill(0xFF0000);
break;
case 1:
s.graphics.beginFill(0x00FF00);
break;
case 2:
s.graphics.beginFill(0x0000FF);
break;
}
s.graphics.drawRect(0, 0, 50, 25);
s.graphics.endFill();
return s;
}
// gui event stuff
btnSend.
addEventListener(MouseEvent.
CLICK, handleButtonClick
);
sendFormData();
}
PHP part for testing if the data arrives:
<?php
$fileh = fopen("formdata.txt", 'a'); fwrite($fileh, $_REQUEST['username'] . ": " . $_REQUEST['email'] . "\n"); ?>
Just be sure to test this
on a server and
not locally (in the sense of, test it through a server, even if it's running on your machine, e.g. wamp - meaning the url must start with http:// not with file:///).