Tutorial: Realizziamo una chat per il nostro sito (Lesson 2)

Spread the love

Cominciamo la nostra seconda lezione sulla creazione di una piccola chat da inserire in un box del nostro sito web, spiegando a cosa servono le righe di comando che abbiamo utilizzato nell’Action Script del pulsante Invia.

 

L’azione:

 

loadVariablesNum (“resp.asp”, 0, “POST”);

 

da l’avvio al inserimento del nuovo messaggio, effettua il refresh dei messaggi e pulisce il nostro campo di testo per inserire i nuovi messaggi.

Lo script di resp.asp, va comunque inserito in codice. Di seguito vedremo l’inserimento effettuato con i commenti per capire meglio passo passo cosa stiamo facendo:

<%
Dim strLinea, FileObject, Instream, intVisite, intTipo, OutStream, i, k, arrMsg(100), fine, allMsg
‘questa stringa permette l’utilizzo semplice in visualizzazione di : “username _ messaggio”
stringa = Trim(Request(“stringa”))
strFile = Server.MapPath(“msg.txt”)
definiamo l’oggetto creato in questo caso i messaggi che andranno in un file di testo
Set FileObject = Server.CreateObject(“Scripting.FileSystemObject”)
‘faccio la lettura del file
intTipo = 1 ‘ lettura
Set InStream = FileObject.OpenTextFile(strFile,IntTipo,true)
‘inseriamo il valore di data e ora al messaggio per fare in modo che in ordine cronologico siano aggiunti nella lista
i = 0
arrMsg(i) = FormatDateTime(Now(),3)&” – “&stringa
‘leggiamo il file di testo ed inseriamo i messaggi
Do While not InStream.AtEndOfStream
StrLinea = InStream.ReadLine()
i=i+1
arrMsg(i) = StrLinea
Loop
Set OutStream = FileObject.CreateTextFile(strFile, true)
‘determiniamo il numero massimo di messaggi
if i>15 then
fine=15
else
fine=i
end if
k=0
‘visualizziamo in Flash i messaggi inserendo il (br) a capo dove necessario
Do While k<=fine
OutStream.WriteLine(arrMsg(k))
allMsg=allMsg&arrMsg(k)&”<br />”
k=k+1
Loop
OutStream.Close
Set OutStream = Nothing
InStream.Close
Set InStream = Nothing
Set FileObject = Nothing
‘inviamo definitivamente i messaggi alla chat
Response.Write(“corpo=”&allMsg)
%>

Ecco, così abbiamo inserito il codice alla nostra chat e potremmo utilizzarla in modalità standard per dare la possibilità agli utenti del vostro sito di scambiare due chiacchiere. Ricordiamo che la versione utilizzata per la realizzazione di questo tutorial è l’ActionScript 4 incluso nella suite Adobe Macromedia Flash CS4 Professional.

Nella prossima ed ultima lezione, vedremo come dare un “tocco di colore” alla nostra chat.

733 commenti su “Tutorial: Realizziamo una chat per il nostro sito (Lesson 2)”

  1. A motivating discussion is worth comment. I believe that you need to write more on this topic, it may not be a taboo subject but usually people don’t discuss such topics. To the next! Many thanks!

    Rispondi
  2. Good site! I truly love how it is easy on my eyes it is. I am wondering how I might be notified when a new post has been made. I’ve subscribed to your RSS which may do the trick? Have a great day!

    Rispondi
  3. I think it is a nice point of view. I most often meet people who rather say what they suppose others want to hear. Good and well written! I will come back to your site for sure!

    Rispondi
  4. I blog quite often and I seriously appreciate your information. This article has truly peaked my interest. I am going to take a note of your website and keep checking for new information about once per week. I subscribed to your RSS feed as well.

    Rispondi
  5. I wanted to check up and let you know how, a great deal I cherished discovering your blog today. I might consider it an honor to work at my office and be able to utilize the tips provided on your blog and also be a part of visitors’ reviews like this. Should a position associated with guest writer become on offer at your end, make sure you let me know.

    Rispondi
  6. I dont think Ive caught all the angles of this subject the way youve pointed them out. Youre a true star, a rock star man. Youve got so much to say and know so much about the subject that I think you should just teach a class about it

    Rispondi
  7. I favored your idea there, I tell you blogs are so helpful sometimes like looking into people’s private life’s and work.At times this world has too much information to grasp. Every new comment wonderful in its own right.

    Rispondi

Lascia un commento