Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    311

    nuovo campo in guestbook [flash8]

    Salve, sono giorni che sbatto la testa in questo problema ma non ne riesco proprio a venire a capo.
    Uso un guestbook costruito seguendo un tutorial on line (del quale non trovo più il link), ha sempre funzionato perfettamente, il problema nasce ora che sto cercando di aggiungere un capo di testo mail.
    Il guestbook è quasi tutto fatto in flash e si appoggia a due file esterni, un guest.xml dove vengono memorizzati i messaggi e un processXML.php

    Il file flash è composto da un campo di testo dinamico "myGuestbook" (dove si visualizzano i messaggi), e da un movie "createMessage" nel quale sono inseriti due campi di testo input "nameField" e "messageField" e due pulsanti "sendButton" e "closeButton" (dove il visitatore scrive il messaggio).

    Nel frame della timeLine principale ho il seguente script:


    previous._visible = false;
    createMessage._visible = false;
    createButton.onRelease = function(){
    this._visible = false;
    this._parent.createMessage._visible = true;
    if (createMessage.nameField.text == ""){
    Selection.setFocus(createMessage.nameField);
    }
    else if (createMessage.messageField.text == ""){
    Selection.setFocus(createMessage.messageField);
    }
    }


    myXML = new XML();
    myXML.ignoreWhite = true;
    receiverXML = new XML();

    myXML.onLoad = function(success){
    myXML.contentType = "text/xml";
    if (success){
    this.showXML();
    }
    else{
    trace("Error loading XML file");
    }
    }
    myIdentifier=Math.round(Math.random()*10000);
    myXML.load("guest.xml?uniq="+myIdentifier);

    receiverXML.onLoad = function(){
    this.contentType = "text/xml";
    _root.currPage = 0;
    this.showXML();
    }
    createMessage.closeButton.onRelease = function(){
    this._parent._visible = false;
    createButton._visible = true;
    }
    createMessage.sendButton.onRelease = function(){
    var myName = this._parent.nameField.text;
    var myMessage = this._parent.messageField.text;
    if (myName == ""){
    this._parent.errorField.text = "please fill out your name";
    Selection.setFocus(this._parent.nameField);
    }
    else if (myMessage == ""){
    this._parent.errorField.text = "please leave a message";
    Selection.setFocus(this._parent.messageField);
    }
    else {
    myXML.firstChild.appendChild(myXML.createElement(" entry"));
    myXML.firstChild.lastChild.attributes.myName = myName;
    myXML.firstChild.lastChild.appendChild(myXML.creat eElement("myText"));
    myXML.firstChild.lastChild.lastChild.appendChild(m yXML.createTextNode(myMessage));
    myXML.sendAndLoad("processXML.php", receiverXML);
    this._parent._visible = false;
    createButton._visible = true;
    }
    }
    XML.prototype.showXML = function(){
    myGuestbook.scroll = 1;
    myGuestbook.htmlText = "";
    var numItems = this.firstChild.childNodes.length;
    var firstItem = numItems - (currPage*showAmount);
    if (currPage == 0) previous._visible = false;
    var lastItem = firstItem - showAmount ;
    if (lastItem<=0) {
    lastItem = 0;
    next._visible = false;
    }
    myCount.text = "Total messages: " + numItems;
    if (firstItem == lastItem+1) nowShowing.text = "Showing message " + firstItem;
    else nowShowing.text = "Showing message " + firstItem + " to " + (lastItem + 1);
    for (i=(firstItem-1); i>= lastItem; i--){
    myGuestbook.htmlText += "" + this.firstChild.childNodes[i].attributes.myName + " dice:\n";
    myGuestbook.htmlText += this.firstChild.childNodes[i].firstChild.firstChild.nodeValue + "\n\n";
    }
    }


    Come posso a questo script aggiungere un nuovo campo di testo "mailField"?
    Ho prvato in vari modi ma non ne sono proprio venuto a capo, spero veramente riusciate ad aiutarmi.
    Grazie.

  2. #2
    Utente di HTML.it L'avatar di CJ 87
    Registrato dal
    Dec 2006
    Messaggi
    43
    Devi sia aggiungerlo nell'AS che nel XML (quindi sempre da as).

    trava e aggiungi:
    codice:
    createMessage.sendButton.onRelease = function(){
    var myName = this._parent.nameField.text;
    var myMail = this._parent.nameField.text;
    var myMessage = this._parent.messageField.text;
    if (myName == ""){
    this._parent.errorField.text = "Inserisci il tuo nome";
    Selection.setFocus(this._parent.nameField); 
    }
    else if (myMessage == ""){
    this._parent.errorField.text = "Inserisci il messaggio";
    Selection.setFocus(this._parent.messageField);
    }else if (myMail == ""){
    this._parent.errorField.text = "Inserisci la tua e-mail";
    Selection.setFocus(this._parent.messageField);
    }else{
    
    myXML.firstChild.appendChild(myXML.createElement("entry"));
    myXML.firstChild.lastChild.attributes.myName = myName;
    myXML.firstChild.lastChild.appendChild(myXML.createElement("myText"));
    myXML.firstChild.lastChild.lastChild.appendChild(myXML.createTextNode(myMessage));
    myXML.firstChild.lastChild.lastChild.lastChild.appendChild(myXML.createTextNode(myMail));
    myXML.sendAndLoad("processXML.php", receiverXML);
    this._parent._visible = false;
    createButton._visible = true;
    }
    }
    L'ho scritto a mano senza flash, vedi se ci sono errori di sintassi da correggere, fammi sapere se va.
    Ciao!
    Ciao, Salvo.

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    311
    Grazie per la risposta.
    Il codice non aveva errori di sintassi ma purtroppo non funziona.
    Ho aggiunto un campo di testo input nameMail ( e nel codice correto o provato quindi a cambiare var myMail = this._parent.nameField.text; con var myMail = this._parent.nameMail.text;) ma non funziona, nel guestbook il messaggio che ricevo presenta solo il nome e il messaggio ma senza mail...
    Nella parte iniziale si fa riferimento al nameField e non al nuovo nameMail:

    previous._visible = false;
    createMessage._visible = false;
    createButton.onRelease = function(){
    this._visible = false;
    this._parent.createMessage._visible = true;
    if (createMessage.nameField.text == ""){
    Selection.setFocus(createMessage.nameField);
    }
    else if (createMessage.messageField.text == ""){
    Selection.setFocus(createMessage.messageField);
    }
    }


    Probabilmente anche in quel punto devo modificare il codice ma pur facendo varie prove non sono riuscito a fare funzionare il tutto...
    Dove può essere la soluzione?

  4. #4
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    311
    Ragazzi nessuno sa aiutarmi? Sono veramente in difficoltà

  5. #5
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    311
    Per ora tralascio il problema perchè è sorta una nuova urgenza: la data nei vari messagi.
    Io vorrei che comparisse anche la data in ogni messaggio inviato. Tramite php lo sprei fare ma siccome quasi tutto il guest è fatto in AS vorrei continuare su questa linea. Come posso quindi integrare al conice e fare comunicare col mio .xml la classe date?
    Il codice AS è quello postato sopra mentre l'xml è il seguente:

    <?xml version="1.0"?><guestbook><entry myName="nomeUtente"><myText>Scrivi qui i tuoi commenti</myText></entry></guestbook>


    mentre il file php è semplicemente:

    <?php
    $file = fopen("guest.xml", "w+") or die("Can't open XML file");
    $xmlString = $HTTP_RAW_POST_DATA;
    if(!fwrite($file, $xmlString)){
    print "Error writing to XML-file";
    }
    print $xmlString."\n";
    fclose($file);
    ?>


    Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.