AS
Código PHP:
System.useCodepage=true;
//BUSCAR LES BUTAQUES SELECCIONADES
import mx.controls.Alert;
//totes les butaques
var butacas:Array = [
bt1_1, bt1_2, bt1_3, bt1_4, bt1_5, bt1_6, bt1_7, bt1_8, bt1_9, bt1_10, bt1_11, bt1_12,
bt2_1, bt2_2, bt2_3, bt2_4, bt2_5, bt2_6, bt2_7, bt2_8, bt2_9, bt2_10, bt2_11, bt2_12,
bt3_1, bt3_2, bt3_3, bt3_4, bt3_5, bt3_6, bt3_7, bt3_8, bt3_9, bt3_10, bt3_11, bt3_12,
bt4_1, bt4_2, bt4_3, bt4_4, bt4_5, bt4_6, bt4_7, bt4_8, bt4_9, bt4_10, bt4_11, bt4_12, bt4_13, bt4_14, bt4_15, bt4_16, bt4_17, bt4_18
];
var butacasState:Array = new Array();
function addSelectState(mc, state) {
butacasState[mc._name] = state;
}
function activaSelectState() {
var textState:Array = new Array();
var name:String;
var file:Array;
for (var i:Number = 0; i<butacas.length; i++) {
name = butacas[i]._name;
butacas[i].gotoAndStop(butacasState[name]);
if (butacasState[name] == "_disable") {
butacas[i].enabled = false;
}
if (butacasState[name] == "_active") {
file = fileDetect(butacas[i]);
textState.push('fila '+file[0]+' seient '+file[1]+'');
}
}
_root.seleccio.text = textState.join(newline);
}
function fileDetect(mc) {
var file = mc._name.split('bt');
file = file[1].split('_');
return file;
}
function eventRelease() {
if (butacasState[this._name] == '_up') {
butacasState[this._name] = '_active';
} else {
butacasState[this._name] = '_up';
}
activaSelectState();
}
function eventOver() {
_root.butaca.text = (fileDetect(this)[0]+" "+fileDetect(this)[1]);
this.gotoAndStop(butacasState[this._name]);
}
function eventOut() {
_root.butaca.text = '';
this.gotoAndStop(butacasState[this._name]);
}
function init() {
for (var i:Number = 0; i<butacas.length; i++) {
butacas[i].onRelease = eventRelease;
butacas[i].onRollOut = eventOut;
butacas[i].onRollOver = eventOver;
addSelectState(butacas[i],'_up');
}
//PHP PER A CARREGAR LES CADIRES OCUPADES
//*********************** ¡¡¡¡PROBLEMA NO SE COMO HACERLO!!! ****************
var xml:XML = new XML();
xml.ignoreWhite=true
xml.onLoad = myOnLoad
var send_lv:LoadVars = new LoadVars();
send_lv.xml = 'true';
send_lv.sendAndLoad("send.php", xml, "POST");
function myOnLoad(success:Boolean) {
for(var i:Number=0;i<xml.firstChild.childNodes.length;i++){
if(xml.firstChild.childNodes[i].nodeName=='espectacle'){
espectacle=xml.firstChild.childNodes[i].firstChild.nodeValue
}
if(xml.firstChild.childNodes[i].nodeName=='venudes'){
trace(xml.firstChild.childNodes[i].firstChild.nodeValue)
butacasState[xml.firstChild.childNodes[i].firstChild.nodeValue]='_disable'
}
}
activaSelectState();
}
}
//*********************** ¡¡¡¡AQUI SE TERMINA EL PROBLEMA!!! ****************
//AQUÍ S'ACABA LA CAPTURA I COMENÇA AMB EL PHP
acceptar_btn.onPress = function() {
lv = new LoadVars();
//PER ENVIAR VARIABLES DE LES CADIRES
var textState:Array = new Array();
var name:String;
var file:Array;
for (var i:Number = 0; i<butacas.length; i++) {
name = butacas[i]._name;
butacas[i].gotoAndStop(butacasState[name]);
if (butacasState[name] == "_disable") {
butacas[i].enabled = false;
}
if (butacasState[name] == "_active") {
file = fileDetect(butacas[i]);
textState.push(file[0]+'#'+file[1]);
}
}
seleccio = textState.join(newline);
// AQUÍ S'ACABA LA INSTRUCCIÓ PER ENVIAR EN FORMAT 1#2
lv.seleccio = seleccio;
lv.zona = "amfiteatre";
lv.nom = espectacle;
lv.ocupades = ocupades;
lv.send("send.php", "_blank", "POST");
var cont:Number = 0;
for (var prop in butacasState) {
if (butacasState[prop] == '_active') {
cont++;
}
}
if (cont>0) {
Alert.show("Ha seleccionat "+cont+" butaca/ques: "+newline+newline+_root.seleccio.text+newline+newline+newline+newline,"Avís");
} else {
Alert.show("Si us plau, seleccioni alguna butaca","Avís");
}
activaSelectState();
};
var espectacle
init();
PHP
Código PHP:
<?php
if($_POST["xml"]=="true"){
header( "Content-type: text/xml; charset=utf-8 ");
$venudes=array('bt1_1','bt1_3','bt1_5');
$xm=new XMLWriter();
$xm->openMemory();
$xm->startElement('cfx:Teatre');
$xm->writeAttribute('xmlns:cfx', "http://www.lynxcraft.com/cfx");
$xm->startElement('espectacle');
$xm->writeCData(utf8_encode("L'obra més llarga de l'any"));
$xm->endElement();
foreach ($venudes as $row) {
$xm->startElement('venudes');
$xm->text($row);
$xm->endElement();
}
$xm->endElement();
echo $xm->outputMemory(true);
}else{
echo ("</br>".utf8_decode($_POST["nom"])."</br>");
// echo ("</br>".$_POST["ocupades"]."</br>");
echo ("</br> La zona és: ".$_POST["zona"]."</br>");
echo ("</br> Les butaques seleccionades són: ");
echo ($_POST["seleccio"]."</br>");
}
?>